protected function formatToCompressionType(string $format): int
    {
        if (!class_exists('Imagick')) {
            return 0; // Not possible.
        }
        switch (($ext = $this->formatToExt($format))) {
            case 'jpg':
                $type = \Imagick::COMPRESSION_JPEG;
                break;

            default:
                $type = \Imagick::COMPRESSION_UNDEFINED;
        }
        return $type;
    }