Create image

echo Html::image('data/files/pic1.jpg');

@param string $file       File
@param array  $attributes Image attributes
@return string
321892
public static function image(string $file, array $attributes = null) : string
    {
        // Add the image link
        $attributes['src'] = $file;
        $attributes['alt'] = (isset($attributes['alt'])) ? $attributes['alt'] : pathinfo($file, PATHINFO_FILENAME);

        return '<img'.Html::attributes($attributes).'>';
    }
168342
public function create($fileId, array $attributes = [])
    {
        $attributes = array_merge($attributes, [
            'file' => $fileId,
        ]);

        return $this->_post("file_links", $attributes);
    }
913761
public function image(string $imageFile, array $attributes = null) : self
    {
        if ($this->validate and ! $imageFile) {
            throw new Exception("Open Graph: Invalid image URL (empty)");
        }

        if (strpos($imageFile, '://') === false and function_exists('asset')) {
            $imageFile = asset($imageFile);
        }

        if ($this->validate and ! filter_var($imageFile, FILTER_VALIDATE_URL)) {
            throw new Exception("Open Graph: Invalid image URL '{$imageFile}'");
        }

        $this->tags[] = $this->createTag('image', $imageFile);

        if ($attributes) {
            $valid = [
                'secure_url',
                'type',
                'width',
                'height',
            ];

            $this->attributes('image', $attributes, $valid);
        }

        return $this;
    }
583129
public function ImageUpload($FieldName, $Attributes = array()) {
      $Result = '<div class="FileUpload ImageUpload">'.
         $this->CurrentImage($FieldName, $Attributes).
         $this->Input($FieldName.'_New', 'file').
         '</div>';
      
      return $Result;
   }
291152
public function image( $file, $rule )
	{
		if( !($file instanceof File) ){
			return false;
		}
		if( $rule ){
			$rule = explode( ',', $rule );
			list( $width, $height, $type ) = getimagesize( $file->getRealPath() );
			if( isset( $rule[2] ) ){
				$imageType = strtolower( $rule[2] );
				if( 'jpeg' == $imageType ){
					$imageType = 'jpg';
				}
				if( image_type_to_extension( $type, false ) != $imageType ){
					return false;
				}
			}
			list( $w, $h ) = $rule;
			return $w == $width && $h == $height;
		} else{
			return in_array( $this->getImageType( $file->getRealPath() ), [1, 2, 3, 6] );
		}
	}
490424
private function createImageTag($filename, $attributes)
    {
        $img = '<ac:image';

        foreach ($attributes as $name => $value) {
            if ($name == 'style') {
                $re = '/float:\s*?(left|right);?/';
                if (preg_match($re, $value, $matches)) {
                    $img .= ' ac:align="' . $matches[1] . '"';
                    $value = preg_replace($re, "", $value, 1);
                }
            }

            $img .= ' ac:' . $name . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"';
        }

        $img .= "><ri:attachment ri:filename=\"$filename\" /></ac:image>";

        return $img;
    }
335431
public function dump(string $file = null):string{
		$file    = $file ?? $this->options->cachefile;
		$imagick = new Imagick;

		$imagick->newImage(
			$this->length,
			$this->length,
			new ImagickPixel($this->options->imagickBG ?? 'transparent'),
			$this->options->imagickFormat
		);

		$imageData = $this->drawImage($imagick);

		if($file !== null){
			$this->saveToFile($imageData, $file);
		}

		return $imageData;
	}
246931
public function make(UploadedFile $file, array $attributes = [])
    {
        return $this->save($file->getClientOriginalName(), file_get_contents($file), $attributes);
    }
1095866
public function setImage($file) {

		if(false === is_string($file)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($file)), E_USER_ERROR);
		}

		if(false === is_file($file)) {
			return trigger_error(sprintf('File "%s" passed to %s() does not exists', $file, __METHOD__), E_USER_ERROR);
		}

		if(false === is_readable($file)) {
			return trigger_error(sprintf('File "%s" passed to %s() is not readable', $file, __METHOD__), E_USER_ERROR);
		}

		$info = @getimagesize($file);

		if(false === is_array($info) || count($info) < 3) {
			return trigger_error(sprintf('File "%s" passed to %s() is not an image', $file, __METHOD__), E_USER_ERROR);
		}

		$this -> image 	 	= @imagecreatefromstring(file_get_contents($file));
		$this -> extension 	= pathinfo($file, PATHINFO_EXTENSION);

		return $this;
	}
647974
protected function save($name, $file, array $attributes)
    {
        $filename = $this->setFilename($name);


        app('filesystem')->disk($this->disk)->put($this->getPath($filename), $file);

        return Media::create(array_merge($attributes, [
            'name' => $name,
            'filename' => $filename,
            'disk' => $this->disk,
            'type' => $this->type,
        ]));
    }
686180
private function createImagens(string $file, array $data, string $pathFile)
    {
        Helper::createFolderIfNoExist(PATH_HOME . "assetsPublic/img");
        foreach ($data as $datum) {
            if (!empty($datum['imagens']) && !file_exists(PATH_HOME . "assetsPublic/img/{$datum['nome']}")) {
                Helper::createFolderIfNoExist(PATH_HOME . "assetsPublic/img/{$datum['nome']}");
                foreach ($datum['imagens'] as $file) {
                    if (!file_exists(PATH_HOME . "assetsPublic/img/{$datum['nome']}/{$file['name']}"))
                        copy($file['content'], PATH_HOME . "assetsPublic/img/{$datum['nome']}/{$file['name']}");
                }
            }
        }
    }
311349
public function image($source, $alt = null, $attributes = array())
	{
		$url = $source;
		
		if (false === strstr($source, '://') && '//' !== substr($source, 0, 2)) {
			$url = $this->cdn($source);
		}
		
		return HTML::image($url, $alt, $attributes);
	}
1077082
public static function upload($file)
    {
        $photo = self::create();

        $image_manager = new ImageManager(['driver' => 'imagick']);

        $disk = Storage::disk(config('mustard.storage.disk', 'local'));

        if (!file_exists($file)) {
            RuntimeException("File $file does not exist");
        }

        $dest_dir = config('mustard.storage.photo.dir', 'mustard/photos');
        $quality = config('mustard.storage.photo.quality', 90);

        $disk->makeDirectory($dest_dir);

        $photo_id = $photo->getKey();

        Queue::push(function ($job) use ($file, $quality, $dest_dir, $photo_id) {
            if (!file_exists($file)) {
                RuntimeException("File $file no longer exists");
            }

            $image_manager = new ImageManager(['driver' => 'imagick']);

            $disk = Storage::disk(config('mustard.storage.disk', 'local'));

            if ($file != "$dest_dir/$photo_id.jpg") {
                $image = $image_manager->make($file);

                $disk->put("$dest_dir/$photo_id.jpg", (string) $image->encode('jpg', $quality));

                $image->destroy();
            }

            $image = $image_manager->make($file)->heighten(83);

            $disk->put("$dest_dir/{$photo_id}_s.jpg", (string) $image->encode('jpg', $quality));

            $image->destroy();

            $image = $image_manager->make($file)->widen(500);

            $disk->put("$dest_dir/{$photo_id}_l.jpg", (string) $image->encode('jpg', $quality));

            $image->destroy();

            $photo = Photo::find($photo_id);

            $photo->processed = true;

            $photo->save();

            $job->delete();
        });

        return $photo;
    }
798573
public function getAttributeTypeFileURL($_file)
    {
        $env = \Environment::get();
        $r = $env->getRecord(
            implode('/', [DIRNAME_ATTRIBUTES . '/' . $this->attributeType->getAttributeTypeHandle() . '/' . $_file]),
            $this->attributeType->getPackageHandle()
        );
        if ($r->exists()) {
            return $r->url;
        }
    }
1216246
public function img($file, $ext=null, $theme=null) {
        
        $this->secondaryTheme($theme);
        
        $img = $this->enqueueFiles($file, $this->container->getIMG(), $ext);
        
        return $img;
        
    }
721201
protected function makeImage($file = null, $quality = null)
  {
    $dir = dirname($file);
    if (!is_dir($dir)) {
      mkdir($dir, 0777, true);
    }

    switch ($this->getTypeByFile($file)) {
      case IMG_JPG:
        return imagejpeg($this->image, $file, $quality ? : static::QUALITY_JPG);
        break;
      case IMG_PNG:
        return imagepng($this->image, $file, $quality ? : static::QUALITY_PNG);
        break;
      case IMG_GIF:
        return imagegif($this->image, $file);
        break;
      default:
        Ex::ThrowError(Ex::BAD_TYPE);
    }
  }
859083
public static function open($file)
    {
        if (is_string($file)) {
            $file = new \SplFileInfo($file);
        }
        if (!$file->isFile()) {
            throw new ImageException('image file not exist');
        }
        return new self($file);
    }