Get image type base on file extension.

@param int $imageFile File path to image.

@return ImageType string Type of image.
189974
private function _getImageTypeFromFileName($imageFile)
    {
        $ext = strtolower((string)pathinfo($imageFile, PATHINFO_EXTENSION));

        if ('jpg' === $ext or 'jpeg' === $ext) {
            return ImageType::JPEG;
        } else if ('gif' === $ext) {
            return ImageType::GIF;
        } else if ('png' === $ext) {
            return ImageType::PNG;
        } else if ('wbm' === $ext or 'wbmp' === $ext) {
            return ImageType::WBMP;
        } else {
            return ImageType::UNKNOWN;
        }
    }
70212
public function getImageConfig($imageType, $size, $property)
	{
		$config = $this->getConfigPrefix().'images.' . $imageType . '.';
		if ($size == 'original')
		{
			$config .= 'original.';
		}
		elseif (!is_null($size))
		{
			$config .= 'sizes.' . $size . '.';
		}
		$config .= $property;
		return \Config::get($config);
	}
1149116
public function getExtension($nameFile){
        $extension = substr( $nameFile, ( strrpos($nameFile, '.') + 1 ) ) ;
        $extension = strtolower( $extension ) ;
        return $extension;
    }
445875
public function getExtensionByFileName($filepath)
    {
        $path = pathinfo($filepath);

        // check if the file has the extenison and we need
        // to lower down the extension (caused unknown extension for uppercased extension)
        if (isset($path['extension'])) {
            return strtolower($path['extension']);
        } else if (is_string($this->getMime())) {
            return str_replace("image/", "", $this->getMime());
        } else if ($this->format != "") {
            return $this->format;
        } else {
            // fallback to enable save image on empty extension. ImageMagick has no problem with this.
            return "jpg";
        }
    }
659801
public static function get(string $srcFile = ''): string
    {
        if (File::exists($srcFile) === false) {
            throw new RuntimeException('Source file does not exist: '.$srcFile);
        }

        $tmp = @\getimagesize($srcFile);
        if (empty($tmp)) {
            throw new RuntimeException('Invalid source file: '.$srcFile);
        }

        return \sprintf('%s:%s', $tmp[0], $tmp[1]);
    }
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;
    }
611641
public function getMimeType()
    {
        if ($this->file instanceof UploadedFile) {
            return $this->file->getClientMimeType();
        }

        return $this->file->getMimeType();
    }
281526
public function getImageSize($file, $type = '')
	{
		// Reset values
		$this->resetValues();

		// Treat image type as unknown if extension or mime type is unknown
		if (!preg_match('/\.([a-z0-9]+)$/i', $file, $match) && empty($type))
		{
			$this->getImagesizeUnknownType($file);
		}
		else
		{
			$extension = (empty($type) && isset($match[1])) ? $match[1] : preg_replace('/.+\/([a-z0-9-.]+)$/i', '$1', $type);

			$this->getImageSizeByExtension($file, $extension);
		}

		return sizeof($this->size) > 1 ? $this->size : false;
	}
863874
public function getMimeType($extension)
    {
        /**
         * check and remove (*.)ext so we only got the extension
         * when wrong define for example *.jpg becomes jpg
         */
        if (false != preg_match("#^.*\.(?P<EXTENSION>[a-z0-9]{2,4})$#i", $extension, $match)) {
            $extension = $match['EXTENSION'];
        }

        $extension  = strtolower($extension);

        if (is_null($this->mimeTypes)) {
            $file = __DIR__.'/../Resources/config/mime.yml';
            if (is_file($file)) {
                $this->mimeTypes = Yaml::parse(file_get_contents($file));
            } else {
                throw new \InvalidArgumentException('Mime file not found, perhaps you need to create it first? (zicht:filemanager:create:mime)');
            }
        }

        if (array_key_exists($extension, $this->mimeTypes)) {
            return $this->mimeTypes[$extension];
        } else {
            throw new \InvalidArgumentException(sprintf('Could not determine mime type on: %s', $extension));
        }
    }
1153278
public function getImageUrl($sFile = null, $bSsl = null)
    {
        if ($sFile) {
            $sValue = $this->getConfig()->getImageUrl($this->isAdmin(), $bSsl, null, $sFile);
        } elseif (($sValue = $this->getViewConfigParam('imagedir')) === null) {
            $sValue = $this->getConfig()->getImageUrl($this->isAdmin(), $bSsl);
            $this->setViewConfigParam('imagedir', $sValue);
        }

        return $sValue;
    }
236271
public function extension(String $type = 'jpeg', Bool $dot = true) : String
    {
        return image_type_to_extension(Helper::toConstant($type, 'IMAGETYPE_'), $dot);
    }
723329
public function imagecolorallocate($imageResource)
	{
		
		return imagecolorallocate(
			$imageResource,
			$this->_r,
			$this->_g,
			$this->_b
		);
		
	}
835022
public static function guessMimeType($extension = '', $isFile = true)
    {
        if ($isFile) {
            $map = config('cripfilesys.mime.map');
            return isset($map[$extension]) ?
                $map[$extension] : 'text/plain';
        }

        return 'dir';
    }
17042
public static function getResponsiveImageVars($dimensions, $imageFile)
    {
        $ret = array();
        $width = 0;
        $aspectRatio = 0;
        $ret['minWidth'] = 0;
        $ret['maxWidth'] = 0;
        if (isset($dimensions['width']) && $dimensions['width'] > 0) {
            $aspectRatio = $dimensions['height'] / $dimensions['width'] * 100;
            $width = $dimensions['width'];
            $ret['widthSteps'] = Kwf_Media_Image::getResponsiveWidthSteps($dimensions, $imageFile);
        }
        $ret['width'] = $width;
        $ret['aspectRatio'] = $aspectRatio;
        return $ret;
    }
1103516
public function getType()
    {
        if($this->_type == null)
        {
            if($path = $this->getPath())
            {
                if(!$this->_type = @filetype($path)) {
                    $this->_type = self::TYPE_UNKNOWN;
                }
            }
        }

        return $this->_type;
    }
270130
public function getImagePath()
    {
        if ($this->imagePath === null) {
            $this->imagePath = '/images/' . strtolower((new \ReflectionClass($this->owner))->getShortName());
        }
        return $this->imagePath;
    }
1131867
protected function loadType($imageType)
	{
		if (isset($this->type[$imageType]))
		{
			return;
		}

		$className = '\FastImageSize\Type\Type' . mb_convert_case(mb_strtolower($imageType), MB_CASE_TITLE);
		$this->type[$imageType] = new $className($this);

		// Create class map
		foreach ($this->supportedTypes[$imageType] as $ext)
		{
			/** @var Type\TypeInterface */
			$this->classMap[$ext] = $this->type[$imageType];
		}
	}