Get the cache location for the given image and width
@param $imageFile Image file located inside the upload directory of the application given as path relative to WCMF_BASE
@param $width
@return String
353195
public static function getCacheLocation($imageFile, $width) {
    // get file name and cache directory
    $baseName = FileUtil::basename($imageFile);
    $directory = self::getCacheDir($imageFile);
    return self::makeRelative($directory.(strlen($width) > 0 ? $width.'-' : '').$baseName);
  }
983925
public function getPicturePath($file, $admin = false, $lang = null, $shop = null, $theme = null)
    {
        return $this->getDir($file, $this->_sPictureDir, $admin, $lang, $shop, $theme);
    }
1355831
public function getImagePath(Image $file, $sizeName = null)
	{
		if ( ! $file instanceof Image) {
			throw new Exception\RuntimeException('Image entity expected');
		}

		$path = $this->getFilesystemDir($file);
		$size = $file->findImageSize($sizeName);
				
		if ($size instanceof ImageSize) {
			$path .= self::RESERVED_DIR_SIZE 
					. DIRECTORY_SEPARATOR
					. $size->getFolderName() 
					. DIRECTORY_SEPARATOR;
		}

		$path .= $file->getRealFileName();

		return $path;
	}
214685
public function setImageFile(File $imageFile = null)
    {
        $this->imageFile = $imageFile;

        if ($imageFile) {
            // It is required that at least one field changes if you are using doctrine
            // otherwise the event listeners won't be called and the file is lost
            $this->modified = new \DateTimeImmutable();
        }

        return $this;
    }
607195
public function resizeImage($imageFile, $imageFieldOptions)
    {
        $image = Image::make($imageFile);

        // check if resize needed
        if (!$this->needResizing($imageFieldOptions)) {
            return $image;
        }

        // resize it according to options
        $width = array_get($imageFieldOptions, 'width');
        $height = array_get($imageFieldOptions, 'height');
        $cropHeight = empty($height) ? $width : $height;
        $crop = $this->getCropOption($imageFieldOptions);

        // crop it if option is set to true
        if ($crop === true) {
            $image->fit($width, $cropHeight, function ($constraint) {
                $constraint->upsize();
            });

            return $image;
        }

        // crop with x,y coordinate array
        if (is_array($crop) && count($crop) == 2) {
            list($x, $y) = $crop;

            $image->crop($width, $cropHeight, $x, $y);

            return $image;
        }

        // or resize it with given width and height
        $image->resize($width, $height, function ($constraint) {
            $constraint->aspectRatio();
            $constraint->upsize();
        });

        return $image;
    }
233291
protected function getImagePath($filename)
    {
        // find file
        foreach (config('imagecache.paths') as $path) {
            // don't allow '..' in filenames
            $image_path = $path.'/'.str_replace('..', '', $filename);
            if (file_exists($image_path) && is_file($image_path)) {
                // file found
                return $image_path;
            }
        }

        // file not found
        abort(404);
    }
740065
private static function getRemoteFileSize($imageUrl)
    {
        $result = curl_init($imageUrl);
        if (!$result) {
            return 0;
        }

        curl_setopt($result, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($result, CURLOPT_HEADER, true);
        curl_setopt($result, CURLOPT_NOBODY, true);

        curl_exec($result);
        $imageSize = curl_getinfo($result, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
        curl_close($result);

        return (int) $imageSize;
    }
1342326
public function open($imageFile){
        $fp = fopen( $imageFile, 'rb'); // Binary read

        if($fp === false ) {
            throw new \Exception(sprintf('Error loading file: "%s".', $imageFile));
        }

        $size = filesize( $imageFile );
        $bytes = fread($fp, $size);
        $bytes = unpack('H*', $bytes); // Unpack as hex
        $bytes = $bytes[1];
        fclose($fp);

        return new GifByteStream($bytes);
    }
1020415
public function getMasterPicturePath($file, $admin = false)
    {
        return $this->getDir($file, $this->_sPictureDir . "/" . $this->_sMasterPictureDir, $admin);
    }
393753
private static function _guessType( $imageFile ){
        // Values from http://php.net/manual/en/image.constants.php starting with IMAGETYPE_GIF.
        // 0 - unknown,
        // 1 - GIF,
        // 2 - JPEG,
        // 3 - PNG
        // 15 - WBMP
        list($width, $height, $type) = getimagesize( $imageFile );

        unset($width, $height);

        if ( 1 == $type) {

            return ImageType::GIF;

        } else if ( 2 == $type) {

            return ImageType::JPEG;

        } else if ( 3 == $type) {

            return ImageType::PNG;

        } else if ( 15 == $type) {

            return ImageType::WBMP;

        }

        return ImageType::UNKNOWN;
    }
510998
public function getPicUrl($file_id,$width=0,$height=0,$water=false,$crop=1,$blur){
        return  $this->storage->getPicUrl($file_id,$width,$height,$water,$crop,$blur);
    }
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;
    }
220790
public function forceSize($width, $height, $saveAsNewFile = false)
    {
        $width = $width <= 0 ? round($this->getRatio() * $height) : $width;
        $height = $height <= 0 ? round($width / $this->getRatio()) : $height;


        return $this->modifyImageHelper(
            function (Imagick $imagick) use ($width, $height) {
                $imagick->resizeimage($width, $height, Imagick::FILTER_CATROM, 1);
            },
            function () use ($width, $height) {
                return $this->newForceImageSizeBasename($width, $height);
            },
            function (ImageFile $file) use ($width, $height) {
                $file->forceSize($width, $height);
            },
            $saveAsNewFile);

    }
1115374
public static String getImageFileFormat(File imageFile) {
        String imageFileName = imageFile.getName();
        String imageFormat = imageFileName.substring(imageFileName.lastIndexOf('.') + 1);
        if (imageFormat.matches("(pbm|pgm|ppm)")) {
            imageFormat = "pnm";
        } else if (imageFormat.matches("(jp2|j2k|jpf|jpx|jpm)")) {
            imageFormat = "jpeg2000";
        }
        return imageFormat;
    }
636499
public static function createFromFile( $imageFile ) {
        if ( ! file_exists( $imageFile ) ) {
            throw new \Exception( sprintf( 'Could not open "%s". File does not exist.', $imageFile ) );
        }

        $type = self::_guessType( $imageFile );
        if ( ImageType::GIF == $type ) {

            return self::_createGif( $imageFile );

        } else if ( ImageType::JPEG == $type ) {

            return self::_createJpeg( $imageFile );

        } else if ( ImageType::PNG == $type ) {

            return self::_createPng( $imageFile );

        } else if ( ImageType::WBMP == $type ) {

            return self::_createWbmp( $imageFile );

        } else {
            throw new \Exception( sprintf( 'Could not open "%s". File type not supported.', $imageFile ) );
        }
    }
278659
public function saveFixedWidth($width, $path = 'i')
    {
        $this->handle->image_resize  = true;
        $this->handle->image_ratio_y = true;
        $this->handle->image_x       = $width;

        $tmp_path = sys_get_temp_dir() . '/';
        $this->handle->process($tmp_path);

        $this->s3->sendFile($tmp_path . $this->handle->file_dst_name, $path, $this->_new_name);
        unlink($tmp_path . $this->handle->file_dst_name);

        return $this->_new_name;
    }
562809
private function resolveResourceThumbnail($defaultImage)
    {
        $baseFolder = $this->getBaseFolder();
        $iconUrl = $baseFolder.DIRECTORY_SEPARATOR.'default_thumbnail.png';
        foreach ($this->getThumbnailBaseFolderPaths() as $path) {
            $imageFilePath = $path.DIRECTORY_SEPARATOR.$defaultImage;

            if (file_exists($imageFilePath) && is_readable($imageFilePath)) {
                $iconUrl = $baseFolder.DIRECTORY_SEPARATOR.$defaultImage;
                break;
            }
        }

        return $iconUrl;
    }