Gets the quality setting based on the extension.

@param string $ext
@param array|null   $transform

@return string
14218
private function getQualityFromExtension($ext, $transform = null): string
    {
        /** @var ConfigModel $settings */
        $config = ImagerService::getConfig();

        switch ($ext) {
            case 'png':
                $pngCompression = $config->getSetting('pngCompressionLevel', $transform);

                return max(100 - ($pngCompression * 10), 1);

            case 'webp':
                return $config->getSetting('webpQuality', $transform);
        }

        return $config->getSetting('jpegQuality', $transform);
    }
509444
private function checkExt($ext)
    {
        return empty($this->config['exts']) ? true : in_array(strtolower($ext), $this->exts);
    }
1298747
public function withAdditionalExtensions(Extension ...$exts): self
    {
        $obj = clone $this;
        $obj->_extensions = $obj->_extensions->withExtensions(...$exts);
        return $obj;
    }
1230711
private function buildExtensionSelect($alias, $extension, $propertyName, $locale, &$additionalFields)
    {
        $extension = $this->extensionManager->getExtension('all', $extension);
        $additionalFields[$locale][] = [
            'name' => $alias,
            'extension' => $extension,
            'property' => $propertyName,
        ];
    }
553497
private function createTargetFilename($source, $transform): string
    {
        /** @var ConfigModel $settings */
        $config = ImagerService::getConfig();

        $useFilenamePattern = $config->getSetting('useFilenamePattern', $transform);
        $hashFilename = $config->getSetting('hashFilename', $transform);
        $shortHashLength = $config->getSetting('shortHashLength', $transform);

        $basename = $source->basename;
        $extension = $source->extension;

        if (isset($transform['format'])) {
            $extension = $transform['format'];
            unset($transform['format']);
        }

        if ($extension === '') {
            // todo : detect from mime type?
        }

        $this->extension = $extension;

        $transformFileString = ImagerHelpers::createTransformFilestring($transform).$config->getConfigOverrideString();

        // If $useFilenamePattern is false, use old behavior with hashFilename config setting.
        if (!$useFilenamePattern) { 
            if ($hashFilename) {
                if (\is_string($hashFilename) && $hashFilename === 'postfix') {
                    return $basename.'_'.md5($transformFileString).'.'.$extension;
                }

                return md5($basename.$transformFileString).'.'.$extension;
            }

            return $basename.$transformFileString.'.'.$extension;
        }

        // New behavior, uses filenamePattern config setting. Much joy.
        $transformFileString = ltrim($transformFileString, '_');
        $fullname = $basename.'_'.$transformFileString;

        $patternFilename = $config->getSetting('filenamePattern', $transform);
        $patternFilename = mb_ereg_replace('{extension}', $extension, $patternFilename);
        $patternFilename = mb_ereg_replace('{basename}', $basename, $patternFilename);
        $patternFilename = mb_ereg_replace('{fullname}', $fullname, $patternFilename);
        $patternFilename = mb_ereg_replace('{transformString}', $transformFileString, $patternFilename);

        $patternFilename = mb_ereg_replace('{basename\|hash}', md5($basename), $patternFilename);
        $patternFilename = mb_ereg_replace('{fullname\|hash}', md5($fullname), $patternFilename);
        $patternFilename = mb_ereg_replace('{transformString\|hash}', md5($transformFileString), $patternFilename);

        $patternFilename = mb_ereg_replace('{basename\|shorthash}', substr(md5($basename), 0, $shortHashLength), $patternFilename);
        $patternFilename = mb_ereg_replace('{fullname\|shorthash}', substr(md5($fullname), 0, $shortHashLength), $patternFilename);
        $patternFilename = mb_ereg_replace('{transformString\|shorthash}', substr(md5($transformFileString), 0, $shortHashLength), $patternFilename);

        return $patternFilename;
    }
1357740
protected function checkExt($file, $ext)
    {
        $extension = strtolower(pathinfo($file->getfilename(), PATHINFO_EXTENSION));

        if (is_string($ext)) {
            $ext = explode(',', $ext);
        }

        if (!in_array($extension, $ext)) {
            return false;
        }

        return true;
    }
123721
public function findMimeType($ext = null) {
		if (empty($ext)) {
			return null;
		}
		return $this->find('all', ['conditions' => [$this->getAlias() . '.ext' => $ext]])->first();
	}
514700
private function getSoundExtensionConstant()
    {
        $retour = [];
        if (empty($this->const_sndsExt)) {
            $constants = $this->getConstants();
            foreach ($constants as $key => $constant) {
                $pos = strpos($key, 'EXT_SNDS');
                if ($pos !== false) {
                    $retour[$key] = $constant;
                }
            }
            $this->const_sndsExt = $retour;
        } else {
            $retour = $this->const_sndsExt;
        }
        return $retour;
    }
593733
public function getAliases($extension = null)
    {
        if ($extension === null) {
            return $this->aliases;
        }
        elseif (isset($this->aliases[$extension])) {
            return $this->aliases[$extension];
        }
        else {
            return null;
        }
    }
1212470
public function getFilesWithExtension($path, $ext = 'php')
    {
        if (is_dir($path)) {
            return new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied"
            ), '/^.+\.'.$ext.'$/i', RecursiveRegexIterator::GET_MATCH);
        } else {
            return [];
        }
    }
717241
private function determineExtension()
    {
        $ext = 'php';
        if (in_array($this->driverClass, $this->extensionToDriver)) {
            $map = array_flip($this->extensionToDriver);
            $ext = $map[$this->driverClass];
        }
        return $ext;
    }
1152334
public function jpegQualitySetting($quality)
    {
        // Work on quality
        $q = is_bool($quality) && $quality ? 72 : (integer) $quality;
        $q = 0 < $q && $q <= 100 ? $q : 72;

        // Apply filter hook
        add_filter('jpeg_quality', function () use ($q) {
            return $q;
        });
    }
496307
public function setTransform(\Jdenticon\Rendering\Transform $transform) 
    {
        $this->transform = $transform === null ? 
            Transform::getEmpty() : $transform;
    }
738100
public static function for_extension($extension)
    {
        $classes = ClassInfo::subclassesFor(DataFormatter::class);
        array_shift($classes);
        $sortedClasses = [];
        foreach ($classes as $class) {
            $sortedClasses[$class] = Config::inst()->get($class, 'priority');
        }
        arsort($sortedClasses);
        foreach ($sortedClasses as $className => $priority) {
            $formatter = new $className();
            if (in_array($extension, $formatter->supportedExtensions())) {
                return $formatter;
            }
        }
    }
166297
function _getExtensions($cert = null, $path = null)
    {
        $exts = $this->_extensions($cert, $path);
        $extensions = array();

        if (is_array($exts)) {
            foreach ($exts as $extension) {
                $extensions[] = $extension['extnId'];
            }
        }

        return $extensions;
    }
420920
public function Quality($quality)
    {
        $quality = $this->castDimension($quality, 'Quality');
        $variant = $this->variantName(__FUNCTION__, $quality);
        return $this->manipulateImage($variant, function (Image_Backend $backend) use ($quality) {
            return $backend->setQuality($quality);
        });
    }
838089
private function checkExt($ext)
    {
        if (!empty($this->allowExts)) {
            return in_array(strtolower($ext), $this->allowExts, true);
        }
        return true;
    }