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;
    }