Is current image format supported by image processor
@param string $filename Path to file
771745
public function isSupportedImageFormat($filename)
	{
		$info = new ImageInfo($filename);
		if ($info->hasError()) {
			$this->container->getLogger()->error($info->getError());
			return false;
		}

		if ( ! $this->isMimeTypeImage($info->getMime())) {
			return false;
		}

		return ImageProcessor\ImageProcessor::isSupportedImageType($info->getType());
	}
737997
public static function fileExists($fileName)
    {
        $fp = @fopen($fileName, 'r', true);
        if (is_resource($fp)) {
            fclose($fp);
            return true;
        }
        return false;
    }
1372470
static public function createFromFile($filename) {
		if (!file_exists($filename))
			throw new Exception('Invalid (filename) parameter! File does not exist!');

		$image_info = getimagesize($filename);
		if ($image_info === false)
			throw new Exception('Invalid (filename) parameter! File is corrupted!');

		switch ($image_info[2]) {
			case IMAGETYPE_JPEG:
			case IMAGETYPE_JPEG2000:
				$image = imagecreatefromjpeg($filename);
				break;
			case IMAGETYPE_PNG:
				$image = imagecreatefrompng($filename);
				break;
			case IMAGETYPE_GIF:
				$image = imagecreatefromgif($filename);
				break;
			case IMAGETYPE_WBMP:
				$image = imagecreatefromwbmp($filename);
				break;
			case IMAGETYPE_BMP:
				$image = imagecreatefrombmp($filename);
				break;
			default:
				throw new Exception('Unknown image format!');
				break;
		}

		return new self($image);
	}
1168426
public static function load($filename)
    {

        $instance = new self;

        // Require GD library
        if (!extension_loaded('gd')) {
            throw new Exception('Required extension GD is not loaded.');
        }

        $instance->filename = $filename;

        $info = getimagesize($instance->filename);

        switch ($info['mime']) {

            case 'image/gif':
                $instance->image = imagecreatefromgif($instance->filename);
                break;

            case 'image/jpeg':
                $instance->image = imagecreatefromjpeg($instance->filename);
                break;

            case 'image/png':
                $instance->image = imagecreatefrompng($instance->filename);

                imagesavealpha($instance->image, true);
                imagealphablending($instance->image, true);

                break;

            default:
                throw new Exception('Invalid image: ' . $instance->filename);
                break;

        }

        $instance->original_info = array(
            'width' => $info[0],
            'height' => $info[1],
            'orientation' => $instance->get_orientation(),
            'exif' => function_exists('exif_read_data') ? $instance->exif = @exif_read_data($instance->filename) : null,
            'format' => preg_replace('/^image\//', '', $info['mime']),
            'mime' => $info['mime']
        );

        $instance->width = $info[0];
        $instance->height = $info[1];

        imagesavealpha($instance->image, true);
        imagealphablending($instance->image, true);

        return $instance;

    }
638854
public function convertTo($filename)
    {
        $outputExtension = pathinfo($filename, PATHINFO_EXTENSION);
        $supportedExtensions = $this->getAllowedConverter($this->extension);

        if (!in_array($outputExtension, $supportedExtensions)) {
            throw new OfficeConverterException("Output extension({$outputExtension}) not supported for input file({$this->basename})");
        }

        $outdir = $this->tempPath;
        $shell = $this->exec($this->makeCommand($outdir, $outputExtension));
        if ($shell['return'] != 0) {
            throw new OfficeConverterException("Convertion Failure! Contact Server Admin.");
        }

        return $this->prepOutput($outdir, $filename, $outputExtension);
    }
341031
public function cssVersion($fileName)
    {
        $filePath = sprintf("%s/../web%s", $this->kernelRootDir, $fileName);

        if (true === file_exists($filePath)) {
            return sprintf("%s?v=%s", $fileName, substr(md5_file($filePath), 0, 5));
        }

        return sprintf("%s?v=%s", $fileName, substr(sha1(microtime()), 0, 6));
    }
840412
final public function saveImage($filename)
	{
		$extension = pathinfo($filename, PATHINFO_EXTENSION);

		if (! is_string($extension)) {
			$extension = image_type_to_extension($this->_image_type);
			$filename .= ".{$extension}";
		}

		switch(strtolower($extension))
		{
			case 'jpeg':
			case 'jpg':
				return $this->imageJPEG($filename);
				break;

			case 'png':
				return $this->imagePNG($filename);
				break;

			case 'gif':
				return $this->imageGIF($filename);

			default:
				trigger_error('Invalid extension or not an image', E_USER_WARNING);
				return false;
		}
	}
1306453
private function _processFile($filename) {
		if ($this->debug) {
			echo "Processing File : " . $filename . PHP_EOL;
		}

		// Reset the tokenizer
		$this->tokenizer->reset();

		// Reset the state of the attributes
		$this->_resetValues();

		// Try to detect the type of file in a MVC framework
		if (stripos($filename, 'view') !== false || stripos($filename, 'layouts') !== false) {
			$this->_isView = true;
		} elseif (stripos($filename, 'model') !== false) {
			$this->_isModel = true;
		} elseif (stripos($filename, 'controller') !== false) {
			$this->_isController = true;
		} elseif (stripos($filename, 'class') !== false) {
			// simple simple data objects
			$this->_isClass = true;
		}

		// Store the file name
		$this->_currentFilename = $filename;

		// By defaut the package name is based on the file name
		$this->_packageName = $this->_extractPackageName($filename);

		// Tokenize the file
		$this->tokenizer->tokenize($filename);

		// Empty PHP file
		if ($this->tokenizer->getTokenNumber() === 0) {
			$this->_checkEmptyFile($filename);
			return; // end the scan
		}

		// Go to the first token
		$token = $this->tokenizer->getCurrentToken();

		// File start
		$this->_processFileStart();

		// Run through every token of the file
		while ($token !== false) {
			// Process the token
			$this->_processToken($token);

			$this->lineNumber = $token->line;

			// Go to the next token
			$token = $this->tokenizer->getNextToken();
		}

		// Test the last token of the file
		if ($this->_isActive('noFileCloseTag')) {
			if ($this->tokenizer->checkPreviousToken(T_CLOSE_TAG)) {
				// Closing tag is not recommended since PHP 5.0
				$this->_writeError('noFileCloseTag', $this->_getMessage('END_FILE_CLOSE_TAG'));
			}
		}

		// Inner HTML is OK for views but not for other classes (controllers, models, ...)
		if ($this->_isActive('noFileFinishHTML') && !$this->_isView) {
			if ($this->tokenizer->checkPreviousToken(T_INLINE_HTML)) {
				$this->_writeError('noFileFinishHTML', $this->_getMessage('END_FILE_INLINE_HTML'));
			}
		}

		// Check for unused private functions
		$this->_checkUnusedPrivateFunctions();

		// Check for unused variables
		$this->_checkUnusedVariables();

		if ($this->_ncssFileClasses > 0 || $this->_ncssFileInterfaces > 0) {
			// Test the file name, only if it contains a class or interface
			$this->_checkFileNaming();
		}

		// Write the count of lines for this file
		if ($this->_lineCountReporter !== null) {
			$this->_lineCountReporter->writeFileCount($this->_packageName, $this->_ncssFileClasses, $this->_ncssFileInterfaces, $this->_ncssFileFunctions, $this->_ncssFileLinesOfCode, $this->_ncssFilePhpdoc, $this->_ncssFileLinesPhpdoc, $this->_ncssFileSingleComment, $this->_ncssFileMultiComment);
		}

		// Reset the suppression warnings
		$this->_fileSuppressWarnings = array();
		$this->_classSuppressWarnings = array();
		$this->_interfaceSuppressWarnings = array();
	}
125131
protected function isPhpFilename(string $filename) : bool
    {
        $extension = pathinfo($filename, PATHINFO_EXTENSION);
        return (strtolower($extension) == 'php');
    }
506609
public function read($fileName)
    {
        $path = $this->getPathBase($fileName);

        if (!file_exists($path)) {
            return;
        }

        $data = file_get_contents($path);
        return $this->data = unserialize($data);
    }
1006203
public static function isVcsFile($fileName)
    {
        foreach (self::$vcsPatterns as $pattern) {
            if (strpos($fileName, $pattern) !== false) {
                return true;
            }
        }
        return false;
    }
297207
public function imageInfo($fileName)
    {
        if ($fileName instanceof ImageInterface) {
            return $fileName;
        }

        $image = $this->filesystem->getFile('files://' . $fileName, new NullableImage());

        return $image;
    }
1126029
public static function isGdFile($filename)
    {
        if (!is_file($filename) || !is_readable($filename)) {
            throw new \InvalidArgumentException(sprintf(
                    '"%s" Is Not A Readable File', $filename
            ));
        }
        $result = false;
        $f = null;
        if (($f = @fopen($filename, 'r'))) {
            if (($id = @fread($f, 3))) {
                $result = ('gd2' === strtolower($id)) ? true : false;
            }
        }
        @fclose($f);

        return $result;
    }
1266586
public function imageCreateJpegfromExif($filename)
    {
        $img = imagecreatefromjpeg($filename);

        if (!function_exists('exif_read_data') || !isset($this->source_info['APP1'])  || strpos($this->source_info['APP1'], 'Exif') !== 0) {
            return $img;
        }

        try {
            $exif = @exif_read_data($filename);
        } catch (Exception $e) {
            $exif = null;
        }

        if (!$exif || !isset($exif['Orientation'])) {
            return $img;
        }

        $orientation = $exif['Orientation'];

        if ($orientation === 6 || $orientation === 5) {
            $img = imagerotate($img, 270, null);
        } elseif ($orientation === 3 || $orientation === 4) {
            $img = imagerotate($img, 180, null);
        } elseif ($orientation === 8 || $orientation === 7) {
            $img = imagerotate($img, 90, null);
        }

        if ($orientation === 5 || $orientation === 4 || $orientation === 7) {
            if(function_exists('imageflip')) {
                imageflip($img, IMG_FLIP_HORIZONTAL);
            } else {
                $this->imageFlip($img, IMG_FLIP_HORIZONTAL);
            }
        }

        return $img;
    }
878116
public function handleFile(string $fileName): void
	{
		$file = $this->getFileInfo($fileName);
		if (strpos($file->type, 'image') !== false) {
			$response = new FileResponse($this->getFullPath($file->name), $file->name, $file->type, false);
			$this->presenter->sendResponse($response);
		} else {
			exit;
		}
	}
193809
private function isReadable($filename)
    {
        $maxPathLength = PHP_MAXPATHLEN - 2;

        if (strlen($filename) > $maxPathLength) {
            throw new IOException(sprintf('Could not check if file is readable because path length exceeds %d characters.', $maxPathLength), 0, null, $filename);
        }

        return is_readable($filename);
    }
506673
public static function canOpenArchive($fileName)
    {
        self::checkRequirements();

        $type = self::detectArchiveType($fileName);
        if ($type !== false && self::canOpenType($type)) {
            return true;
        }

        return false;
    }