Try to detect quality of jpeg using imagick extension

@param  string  $filename  A complete file path to file to be examined
@return int|null  Quality, or null if it was not possible to detect quality
551832
private static function detectQualityOfJpgUsingImagickExtension($filename)
    {
        if (extension_loaded('imagick') && class_exists('\\Imagick')) {
            try {
                $img = new \Imagick($filename);

                // The required function is available as from PECL imagick v2.2.2
                if (method_exists($img, 'getImageCompressionQuality')) {
                    return $img->getImageCompressionQuality();
                }
            } catch (\Exception $e) {
                // Well well, it just didn't work out.
                // - But perhaps next method will work...
            }
        }
        return null;
    }
428602
public function locate($filename)
    {
        $basename = preg_replace('~\.[^.]+$~', '', basename($filename));

        if (isset($this->map[$basename])) {
            return $this->root . '/' . $this->map[$basename];
        }

        return null;
    }
1163416
private function  &getImageSource($filename) {

        $image = NULL;
        $extesion = self::getFileExt($filename);
        switch ( $extesion ) {

            case 'gif':
                $image = imagecreatefromgif($filename);
                break;

            case 'png':
                $image = imagecreatefrompng($filename);
                break;

            case 'jpg':
            case 'jpeg':
                $image = imagecreatefromjpeg($filename);
                break;

        }
        return $image;
    }
716175
public function getMimeType($filename)
	{
	    $mimetype = false;
	    
	    if(function_exists('finfo_fopen')) 
	    {
	       $mimetype = finfo_fopen($filename);
	    } 
	    elseif(function_exists('getimagesize')) 
	    {
	       $mimetype = getimagesize($filename);
	    } 
	    elseif(function_exists('exif_imagetype')) 
	    {
	       $mimetype = exif_imagetype($filename);
	    } 
	    elseif(function_exists('mime_content_type')) 
	    {
	       $mimetype = mime_content_type($filename);
	    }
	    
	    return $mimetype['mime'];
	}
1351630
private function getDispersionPath($fileName)
    {
        $char           = 0;
        $dispersionPath = DIRECTORY_SEPARATOR . 'original_image' . DIRECTORY_SEPARATOR;

        while ($char < 2 && $char < strlen($fileName)) {
            /** @noinspection IsEmptyFunctionUsageInspection */
            if (empty($dispersionPath)) {
                $dispersionPath = DIRECTORY_SEPARATOR . ('.' === $fileName[$char] ? '_' : $fileName[$char]);
            } else {
                $dispersionPath =
                    $this->addDirectorySeparator($dispersionPath) . ('.' === $fileName[$char] ? '_' : $fileName[$char]);
            }

            $char++;
        }

        return $dispersionPath . DIRECTORY_SEPARATOR;
    }
1301396
public static function getImageDpi($filename)
    {
        $a = fopen($filename, 'r');
        $string = fread($a, 20);
        fclose($a);
        $data = bin2hex(mb_substr($string, 14, 4));
        $x = mb_substr($data, 0, 4);
        $y = mb_substr($data, 0, 4);

        return [hexdec($x), hexdec($y)];
    }
931798
public function getMimeType($filename)
    {
        $file_info = pathinfo($filename);
        $extension = isset($file_info['extension']) ? $file_info['extension'] : '';

        if (isset(self::$mimeTypeMap[$extension])) {
            $mime = self::$mimeTypeMap[$extension];
        } else {
            $finfo = finfo_open(FILEINFO_MIME_TYPE);
            $mime = finfo_file($finfo, $filename);
        }
        return $mime;
    }
598402
protected function getImagesizeUnknownType($filename)
	{
		// Grab the maximum amount of bytes we might need
		$data = $this->getImage($filename, 0, Type\TypeJpeg::JPEG_MAX_HEADER_SIZE, false);

		if ($data !== false)
		{
			$this->loadAllTypes();
			foreach ($this->type as $imageType)
			{
				$imageType->getSize($filename);

				if (sizeof($this->size) > 1)
				{
					break;
				}
			}
		}
	}
1299792
private function guessFromExtension($filename)
    {
        $output = 'text';
        $pInfo = pathinfo($filename);
        if (isset($pInfo['extension'])) {
            foreach ($this->fileTypes as $extension => $lexer) {
                if ($extension === $pInfo['extension']) {
                    return $lexer;
                }
            }
        }

        return $output;
    }
737997
public static function fileExists($fileName)
    {
        $fp = @fopen($fileName, 'r', true);
        if (is_resource($fp)) {
            fclose($fp);
            return true;
        }
        return false;
    }
193093
public static function isGifFile($filename)
    {
        try {
            $image = new ImageFile($filename);
            if (strtolower($image->getMime()) !== @image_type_to_mime_type(IMAGETYPE_GIF)) {
                return false;
            }

            return true;
        } catch (\RuntimeException $ex) {
            return false;
        }
    }
342433
protected function getFileName (string $fileName)
    {
        if (!$fileName && filter_var ($fileName, FILTER_VALIDATE_URL) === false) {
            return null;
        }

        $explodeFileURL = explode ('/', $fileName);
        $fileName       = end ($explodeFileURL);

        return sanitizeString (pathinfo ($fileName, PATHINFO_FILENAME)) . '.' . pathinfo ($fileName, PATHINFO_EXTENSION);
    }
519920
public static function isJpegFile($filename)
    {
        try {
            $image = new ImageFile($filename);
            if (strtolower($image->getMime()) !== @image_type_to_mime_type(IMAGETYPE_JPEG)) {
                return false;
            }

            return true;
        } catch (\RuntimeException $ex) {
            return false;
        }
    }
202327
public function filename($filename = null)
    {
        if ($filename === null) {
            return $this->_filename;
        }
        $this->_filename = $filename;
    }
138581
public function fileName($fileName = null)
    {
        if (func_num_args() > 0) {
            $parts = pathinfo($this->_name);
            $this->_name = "{$parts['dirname']}/{$fileName}.{$parts['extension']}";
            return $this;
        }
        return pathinfo($this->_name, PATHINFO_FILENAME);
    }
1346109
public function getFile($fileName)
    {
        $result = false;

        if (isset($_FILES[$fileName])) {
            $result = $_FILES[$fileName];
        }

        return $result;
    }
123407
public function getNameWithoutExtension($fileName)
    {
        $lastDot = strrpos($fileName, '.');

        if (!$lastDot) {
            return $fileName;
        }

        return substr($fileName, 0, $lastDot);
    }