Loads image file to RAM

@param string $pathToFile Path to loaded file
@throws ImageException
964229
private function open($pathToFile)
    {
        $this->pathToFile = $pathToFile;
        if (!file_exists($this->pathToFile)) {
            throw new ImageException("File " . ($this->pathToFile) . " not found.", ImageException::AccessException);
        }
        $tmpImageSize = getimagesize($this->pathToFile);
        $this->width = (int)$tmpImageSize[0];
        $this->height = (int)$tmpImageSize[1];
        $this->type = (int)$tmpImageSize[2];
        switch ($this->type) {
            case self::GIF:
                $this->resource = imagecreatefromgif($this->pathToFile);
                break;
            case self::JPG:
                $this->resource = imagecreatefromjpeg($this->pathToFile);
                break;
            case self::PNG:
                $this->resource = imagecreatefrompng($this->pathToFile);
                break;
            case self::BMP:
                $this->resource = imagecreatefromwbmp($this->pathToFile);
                break;
            default:
                throw new ImageException("Unknown type of file " . ($this->pathToFile) . ".", ImageException::UnsupportedFormatException);
                break;
        }
    }
854835
protected function saveCache(&$config, $pathToFile, $cacheIndex)
    {
        if (null !== $config['data']) while ($cacheIndex > 0){
            --$cacheIndex;
            $cache = $this->getCacheClass($cacheIndex);
            $cache->store($pathToFile, $config['data']);
            $this->addCacheExtras($config, $cacheIndex, 'stored');
        }
    }
1312071
protected function writeImageFile(ImageInterface $image, ImagePathInterface $path) {
		$filename = sanitize_path(implode(DIRECTORY_SEPARATOR, [
		    $this->getOption('root'),
    		/**
    		 * The stack prefix is the part of the URL that is used to detect wich stack to trigger.
    		 * This implementation aims to store a file at the exact same URL so next requests could be served statically.
    		 */
		    $this->getOption('use_prefix', false) ? $path->getPrefix() : null,
		    $path->getPath(),
		]));
		$dirname = dirname($filename);
		if (!is_dir($dirname)) {
		    @mkdir($dirname, $this->getOption('mode', 0755), true);
			if (!is_dir($dirname)) {
    			throw new StorageBackendException(sprintf('Cannot create dir %s', $dirname), StorageBackendException::CANNOT_CREATE_DIR);
			}
		}
		if (!file_put_contents($filename, $image->getBinaryContent())) {
			throw new StorageBackendException(sprintf('Cannot write file %s', $filename), StorageBackendException::CANNOT_WRITE_FILE);
		}
	}
395420
private function addFile($pathToAdd, $fileName = null)
    {
        if (!$fileName) {
            $info = pathinfo($pathToAdd);
            $fileName = isset($info['extension']) ?
                $info['filename'].'.'.$info['extension'] :
                $info['filename'];
        }

        $this->repository->addFile($pathToAdd, $this->getInternalPath().$fileName);
    }
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;
    }
447688
protected function _load($url)
    {
        $file = $this->_locate($url);
        $type = pathinfo($file, PATHINFO_EXTENSION);

        if(in_array($type, $this->getFileTypes()))
        {
            if(!$this->_source = file_get_contents($file)) {
                throw new RuntimeException(sprintf('The template "%s" cannot be loaded.', $file));
            }
        }
        else $this->_source = $this->getTemplate()->loadFile($file)->render($this->getData());

        return $this->_source;
    }
1121274
public function save($pathToFile = null, $type = null, $jpgQuality = null)
    {
        if ($pathToFile === null) $pathToFile = $this->pathToFile;
        if ($type === null) $type = $this->type;
        if ($jpgQuality === null) $jpgQuality = $this->jpgQuality;
        switch ($type) {
            case self::GIF:
                imagegif($this->resource, $pathToFile);
                break;
            case self::JPG:
                imagejpeg($this->resource, $pathToFile, $jpgQuality);
                break;
            case self::PNG:
                imagepng($this->resource, $pathToFile);
                break;
            case self::BMP:
                imagewbmp($this->resource, $pathToFile);
                break;
            default:
                throw new ImageException("Unknown type of file " . ($this->pathToFile) . ".", ImageException::UnsupportedFormatException);
                break;
        }
        $this->pathToFile = $pathToFile;
    }
1043865
function cleanFile(pathToFile) {
  try {
    fs.unlinkSync(pathToFile);
  } catch (err) {
    switch (err.code) {
      case 'ENOENT':
        return;
      default:
        throw new Error(err);
    }
  }
}
1128540
protected function readImage()
    {
        // set default path
        $path = $this->pathFile;

        // handle caching
        if (!empty($this->pathCache)) {
            // write / refresh cache file if necessary
            if (!$this->isCached()) {
                $this->writeCache();
            }

            // replace path if file is cached
            if ($this->isCached()) {
                $path = $this->pathCache;
            }

        }

        // get image information
        $read = @getimagesize($path);
        if (false === $read) {
            throw new \RuntimeException(
                sprintf(
                    "Couldn't read image at %s",
                    $path
                )
            );
        }

        // detect image type
        switch ($read[2]) {
            case IMAGETYPE_GIF:
                $this->image = @imagecreatefromgif($path);
                break;

            case IMAGETYPE_JPEG:
                $this->image = @imagecreatefromjpeg($path);
                break;

            case IMAGETYPE_PNG:
                $this->image = @imagecreatefrompng($path);
                break;

            default:
                // image type not supported
                throw new \UnexpectedValueException(
                    sprintf(
                        'Image type %s not supported',
                        image_type_to_mime_type($read[2])
                    )
                );
        }

        if (false === $this->image) {
            throw new \RuntimeException(
                sprintf(
                    "Couldn't read image at %s",
                    $path
                )
            );
        }

        // set image dimensions
        $this->width = $read[0];
        $this->height = $read[1];

        // set mime type
        $this->mimeType = $read['mime'];

        // set modified date
        $this->modified = @filemtime($path);
    }
284110
static public function createFromFile($pathname)
    {
        if (!file_exists($pathname)) {
            throw new ImageFileNotFoundException($pathname);
        }
        $ii = getimagesize($pathname);
        $width = $ii[0];
        $height = $ii[1];
        $imagetype = $ii[2];
        $last_modified = filemtime($pathname);
        $exif = @exif_read_data($pathname);
        if (isset($exif['Orientation'])) {
            $orientation = $exif['Orientation'];
        } else {
            $orientation = 0;
        }
        return new static($pathname, $width, $height, $imagetype, $last_modified, $orientation);
    }
167771
public static function setCachePath($pathCacheFile)
    {
        self::$cacheEnable = false;

        if (!empty($pathCacheFile) && file_exists($pathCacheFile)) {
            self::$cacheEnable = true;
            self::$cachePath   = $pathCacheFile;
        }
        elseif (!empty($pathCacheFile) && !file_exists(dirname($pathCacheFile))) {
            self::$cacheEnable = false;
            self::$cachePath   = $pathCacheFile;
        }
        elseif (!empty($pathCacheFile) && touch($pathCacheFile)) {
            unlink($pathCacheFile);
            self::$cacheEnable = true;
            self::$cachePath   = $pathCacheFile;
        }
    }
1095591
protected function determineOutputFormat($pathToImage)
    {
        $outputFormat = pathinfo($pathToImage, PATHINFO_EXTENSION);

        if ($this->outputFormat != '') {
            $outputFormat = $this->outputFormat;
        }

        $outputFormat = strtolower($outputFormat);

        if (! $this->isValidOutputFormat($outputFormat)) {
            $outputFormat = 'jpg';
        }

        return $outputFormat;
    }
127324
protected function searchCache($pathToFile, &$config)
    {
        $cacheIndex = 0;
        if (!isset($config['data'])) {
            $config['data'] = null;
        }
        if (!is_array($config['extras']['cache'])) {
            $config['extras']['cache'] = [];
        }
        if (is_array($this->cacheStack)) {
            for ($cacheIndex = 0; $cacheIndex < $this->cacheDepth; $cacheIndex++) {
                $cache = $this->getCacheClass($cacheIndex);
                if ($cache->isStored($pathToFile)) {
                    $config['data'] = $cache->restore($pathToFile);
                    $this->addCacheExtras($config, $cacheIndex, 'restored');
                    break;
                } else {
                    $this->addCacheExtras($config, $cacheIndex, 'not found');
                }
            }
        }
        $this->saveCache($config, $pathToFile, $cacheIndex);
    }
318651
public function upload($imageFile)
    {
        if ($imageFile instanceof UploadedFile) {
            if ($imageFile->isValid()) {
                $pictureId = $this->pictureIdGenerator->generate($imageFile);
                if(false === $this->disk->putFileAs('', $imageFile, $this->pictureUrlManager->getOriginalPath($pictureId))){
                    throw new UploadException();
                }
                return $pictureId;
            } else {
                throw new UploadException($imageFile->getErrorMessage());
            }
        } else {
            throw new UploadException();
        }
    }
132763
public function load($pathToFile)
    {
        $config = [
            'data' => null,
            'extras' => [
                'isUpdated'  => false,
                'fileName'   => str_replace('\\', '/', $pathToFile),
                'fileExists' => file_exists($pathToFile)]
        ];

        $this->searchCache($pathToFile, $config);
        if (null === $config['data']) {
            $config['extras']['isUpdated'] = true;
            if (file_exists($pathToFile)) {
                switch (substr($pathToFile, strrpos($pathToFile, '.'))) {
                    case '.yml':
                        $config['data'] = Yaml::parse(file_get_contents($pathToFile));
                        break;

                    case '.json':
                        $data = file_get_contents($pathToFile);
                        $config['data'] = json_decode($data, true);
                        break;

                    default:
                        $config['data'] = require $pathToFile;
                }

                $this->saveCache($config, $pathToFile, $this->cacheDepth);
            } else {
                $config['data'] = [];
            }
        } else {
        }
        return $config;
    }
444808
public File download(String pathToFile, String extension) {
        return fileDownloadRequest.download(pathToFile, extension);
    }
1194194
function loadImage($path_imagen)
    {
        //---Tomar las dimensiones de la imagen
        $info = getimagesize($path_imagen);

        $this->width = $info[0];
        $this->height = $info[1];
        $this->type = $info[2];
        $this->path_image = $path_imagen;

        //---Dependiendo del tipo de imagen crear una nueva imagen
        switch($this->type)
        {
            case IMAGETYPE_JPEG:
                $this->image = imagecreatefromjpeg($path_imagen);
                break;
            case IMAGETYPE_GIF:
                $this->image = imagecreatefromgif($path_imagen);
                break;
            case IMAGETYPE_PNG:
                $this->image = imagecreatefrompng($path_imagen);
                break;
        }
    }