public static function getType($path, $outputFormat = null, array $imgInfo = null)
    {
        $imgInfo = $imgInfo ?: self::getSize($path);

        if ($outputFormat) {
            switch ($outputFormat) {
                case 'png': $type = ImageFile::TYPE_PNG; break;
                case 'gif': $type = ImageFile::TYPE_GIF; break;
                case 'wbmp':
                case 'bmp': $type = ImageFile::TYPE_BMP; break;
                case 'webp': $type = ImageFile::TYPE_WEBP; break;
                case 'jpeg':
                case 'jpg':
                default: $type = ImageFile::TYPE_JPG;
            }
        } else {
            $type = $imgInfo['mime'];
        }

        return $type;
    }
public static function getType($path, $outputFormat = null, array $imgInfo = null)
    {
        $imgInfo = $imgInfo ?: self::getSize($path);

        if ($outputFormat) {
            switch ($outputFormat) {
                case 'png': $type = ImageFile::TYPE_PNG; break;
                case 'gif': $type = ImageFile::TYPE_GIF; break;
                case 'wbmp':
                case 'bmp': $type = ImageFile::TYPE_BMP; break;
                case 'webp': $type = ImageFile::TYPE_WEBP; break;
                case 'jpeg':
                case 'jpg':
                default: $type = ImageFile::TYPE_JPG;
            }
        } else {
            $type = $imgInfo['mime'];
        }

        return $type;
    }
public static function getType ( $ path , $ outputFormat = null , array $ imgInfo = null ) { $ imgInfo = $ imgInfo ? : self :: getSize ( $ path ) ; if ( $ outputFormat ) { switch ( $ outputFormat ) { case 'png' : $ type = ImageFile :: TYPE_PNG ; break ; case 'gif' : $ type = ImageFile :: TYPE_GIF ; break ; case 'wbmp' : case 'bmp' : $ type = ImageFile :: TYPE_BMP ; break ; case 'webp' : $ type = ImageFile :: TYPE_WEBP ; break ; case 'jpeg' : case 'jpg' : default : $ type = ImageFile :: TYPE_JPG ; } } else { $ type = $ imgInfo [ 'mime' ] ; } return $ type ; }
Get image type based on given format or mime info
@param null|string $outputFormat - if null, mime info is used
@param null|array $imgInfo
@return string
Get image type based on given format or mime info