Gets the MIME Type of the given image.

The file must be exists.

@param string $image
@return string
12014
private static function getMimeTypeOfImage($image)
    {
        static $mimes;
        if ($mimes === null) {
            $mimes = [
                'cod'  => 'image/cis-cod',
                'ras'  => 'image/cmu-raster',
                'fif'  => 'image/fif',
                'gif'  => 'image/gif',
                'ief'  => 'image/ief',
                'jpeg' => 'image/jpeg',
                'jpg'  => 'image/jpeg',
                'jpe'  => 'image/jpeg',
                'png'  => 'image/png',
                'tiff' => 'image/tiff',
                'tif'  => 'image/tiff',
                'mcf'  => 'image/vasa',
                'wbmp' => 'image/vnd.wap.wbmp',
                'fh4'  => 'image/x-freehand',
                'fh5'  => 'image/x-freehand',
                'fhc'  => 'image/x-freehand',
                'ico'  => 'image/x-icon',
                'pnm'  => 'image/x-portable-anymap',
                'pbm'  => 'image/x-portable-bitmap',
                'pgm'  => 'image/x-portable-graymap',
                'ppm'  => 'image/x-portable-pixmap',
                'rgb'  => 'image/x-rgb',
                'wxd'  => 'image/x-windowdump',
                'xbm'  => 'image/x-xbitmap',
                'xpm'  => 'image/x-xpixmap',
            ];
        }

        $ext = pathinfo($image, PATHINFO_EXTENSION);
        $type = isset($mimes[$ext]) ? $mimes[$ext] : 'application/octet-stream'; // RFC 2046 states in section 4.5.1: The "octet-stream" subtype is used to indicate that a body contains arbitrary binary data.

        return $type;
    }
1271482
protected function getMime($file)
    {
        $finfo = finfo_open(FILEINFO_MIME_TYPE);

        return finfo_file($finfo, $file->getRealPath() ?: $file->getPathname());
    }
838194
public function loadFromString($image)
    {
        $resource = @imagecreatefromstring($image);

        if (!is_resource($resource)) {
            throw new Exception\RuntimeException('image could not be loaded');
        }

        return $resource;
    }
300418
protected function randomColor($image)
    {
        if($this->ismono) {
            return imagecolorallocatealpha($image, $this->monocolor[0], $this->monocolor[1], $this->monocolor[2], $this->rand(0, 96));
        }
        return imagecolorallocate($image, $this->rand(0, 255), $this->rand(0, 255), $this->rand(0, 255));
    }
1137754
public function getRequest(Image $image, $responseType = self::RESPONSE_TYPE_OBJECT)
    {
        return $this->request($image, $responseType);
    }
488969
protected function _getImage($Image = null) {
		if (is_string($Image)) {
			$class = 'Imagine\\' . $this->config('engine') . '\Imagine';
			$Imagine = new $class();
			return $Imagine->open($Image);
		}
		if (!empty($this->_image)) {
			return $this->_image;
		}
		throw new \RuntimeException('Could not get the image object!');
	}
509314
public function apply( $image ) {

        imagefilter($image->getCore(), IMG_FILTER_PIXELATE, $this->amount, true);
        return $image;
    }
565709
private function getMimeType(AbstractLocalImage $image)
    {
        $mimeType = 'application/not-supported';
        $realpath = $image->getRealpath();
        if (\is_string($realpath)) {
            $mimeType = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $realpath);
        } else {
            $content = $image->getContent();
            if (null !== $content) {
                $mimeType = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $content);
            }
        }

        if ('text/html' == $mimeType || 'text/plain' == $mimeType) {
            if ($this->isSvg($image)) {
                $mimeType = 'image/svg+xml';
            }
        }

        return $mimeType;
    }
79416
public function getInfo($image)
    {
        if (DriverInterface::IMAGE_STORAGE_STRING == $this->getImageStorage($image)) {
            $image = 'data://application/octet-stream;base64,'  . base64_encode($image);
        }
        return getimagesize($image);
    }
758459
public function get_mime($file){
        $type = $this->get_content_type($file);
        if( $type ){
            $type = array_map('trim', explode(';', $type));
            return $type[0];
        }else{
            return '';
        }
    }
1298031
private function getPathsForUrl($image)
    {
        /** @var ConfigModel $settings */
        $config = ImagerService::getConfig();

        $runtimeImagerPath = Craft::$app->getPath()->getRuntimePath().'/imager/';
        $convertedImageStr = StringHelper::toAscii(urldecode($image));
        $this->transformPath = ImagerHelpers::getTransformPathForUrl($convertedImageStr);

        $urlParts = parse_url($convertedImageStr);
        $pathParts = pathinfo($urlParts['path']);
        $queryString = $config->getSetting('useRemoteUrlQueryString') ? ($urlParts['query'] ?? '') : '';

        $this->path = FileHelper::normalizePath($runtimeImagerPath.$this->transformPath.'/');
        $this->url = $image;
        $this->basename = str_replace(' ', '-', $pathParts['filename']).($queryString !== '' ? '_'.md5($queryString) : '');
        $this->extension = $pathParts['extension'] ?? '';
        $this->filename = FileHelper::sanitizeFilename($this->basename.'.'.$this->extension);

        try {
            FileHelper::createDirectory($this->path);
        } catch (Exception $e) {
            Craft::error($e->getMessage(), __METHOD__);
            throw new ImagerException($e->getMessage(), $e->getCode(), $e);
        }
    }
163232
private function _computeResolution($image)
    {
        $this->res = "MED";
        if(preg_match("/HiRes/i", $image))
            $this->res = "HIGH";
        elseif (preg_match("/LowRes/i", $image))
            $this->res = "LOW";
        elseif (preg_match("/Thumb/i", $image))
            $this->res = "THUMB";
        elseif (preg_match("/MediumRes/i", $image))
            $this->res = "MED";
    }
316980
public function apply( $image ) {
        if ( $this->type === 'ordered' ) {
            return $this->ordered( $image );
        } else if ( $this->type === 'diffusion' ) {
            return $this->diffusion( $image );
        }
        throw new \Exception( sprintf( 'Invalid dither type "%s".', $this->type ) );
    }
293543
public function apply( $image ) {

        imagefilter($image->getCore(), IMG_FILTER_COLORIZE, $this->red, $this->green, $this->blue);
        return $image;
    }
1294708
public static function getMimeType($file)
    {
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        $type = finfo_file($finfo, $file);
        finfo_close($finfo);

        return $type;
    }
1172576
public function run(Image $image)
    {
        if (is_null($this->bg)) {
            return $image;
        }

        $color = (new Color($this->bg))->formatted();

        if ($color) {
            $new = $image->getDriver()->newImage($image->width(), $image->height(), $color);
            $new->mime = $image->mime;
            $image = $new->insert($image, 'top-left', 0, 0);
        }

        return $image;
    }
160404
private function checkImageUrl($image)
    {
        if ( ! filter_var($image, FILTER_VALIDATE_URL)) {
            throw Exceptions\InvalidImageUrlException::make($image);
        }

        return $image;
    }