protected function getDesiredImageQuality($ext, $format)
    {
        switch ($ext) {
            case 'jpeg':
            case 'jpg':
                $qualityConfig = $this->jpegQuality;
                break;

            case 'png':
                $qualityConfig = $this->pngQuality;
                break;

            default:
                $qualityConfig = null;
        }

        if (empty($qualityConfig)) {
            return null;
        }
        if (is_array($qualityConfig)) {
            if (isset($qualityConfig[$format])) {
                return $qualityConfig[$format];
            }
            if (isset($qualityConfig['default'])) {
                return $qualityConfig['default'];
            }
        }
        return $qualityConfig;
    }