简体   繁体   English

TYPO3 FileReference将tiff和bmp转换为gif

[英]TYPO3 FileReference converts tiff and bmp to gif

Uploading and using tiff or bmp files in TYPO3 and including them via f:image results them in beeing converted into gif files. 在TYPO3中上载和使用tiff或bmp文件并通过f:image包含它们会导致将它们转换为gif文件。 Im using ImageMagick. 我正在使用ImageMagick。 I couldn't find anything about this issue but i wonder, because even uploading 100% jpg files results into double compression, while uploading bmp and tiff doesn't. 我找不到关于此问题的任何信息,但我想知道,因为即使上传100%jpg文件也会导致双重压缩,而上传bmp和tiff却没有。 Any ideas how to configure typo3 to convert tiff and bmp into jpg and not gif? 有什么想法如何配置typo3将tiff和bmp转换为jpg而不是gif? Can't imagine that this is the right behavior. 无法想象这是正确的行为。

edit: 编辑:

i found out that the decision for the output format is done at 我发现输出格式的决定是在

TYPO3\CMS\Core\Resource\Processing\AbstractGraphicalTask::determineTargetFileExtension

If there is no configuration given it will use gif or png for all non-jpg images. 如果没有配置,它将对所有非jpg图像使用gif或png。 I overloaded the 我超载了

\TYPO3\CMS\Core\Resource\Processing\ImageCropScaleMaskTask 

which extends the AbstractGraphicalTask and rewrote the function to properly convert bmp and tiff. 扩展了AbstractGraphicalTask​​并重写了函数以正确转换bmp和tiff。

Overwrite the default fal config in ext_localconf.php 覆盖ext_localconf.php中的默认fal配置

$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['processingTaskTypes']['Image.CropScaleMask'] = \i3\I3Content\Resource\Processing\ImageCropScaleMaskTask::class;

New function: 新功能:

protected function determineTargetFileExtension() {

    if (!empty($this->configuration['fileExtension'])) {
        $targetFileExtension = $this->configuration['fileExtension'];
    } else {
        // explanation for "thumbnails_png"
        // Bit0: If set, thumbnails from non-jpegs will be 'png', otherwise 'gif' (0=gif/1=png).
        // Bit1: Even JPG's will be converted to png or gif (2=gif/3=png)

        $targetFileExtensionConfiguration = $GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails_png'];
        if ($this->getSourceFile()->getExtension() === 'jpg' || $this->getSourceFile()->getExtension() === 'jpeg') {
            if ($targetFileExtensionConfiguration == 2) {
                $targetFileExtension = 'gif';
            } elseif ($targetFileExtensionConfiguration == 3) {
                $targetFileExtension = 'png';
            } else {
                $targetFileExtension = 'jpg';
            }
        } else {
            // check if a png or a gif should be created
            if ($targetFileExtensionConfiguration == 1 || $this->getSourceFile()->getExtension() === 'png') {
                $targetFileExtension = 'png';
            } elseif($this->getSourceFile()->getExtension() === 'tif' || $this->getSourceFile()->getExtension() === 'tiff' || $this->getSourceFile()->getExtension() === 'bmp') {
                $targetFileExtension = 'jpg';
            } else {
                // thumbnails_png is "0"
                $targetFileExtension = 'gif';
            }
        }
    }

    return $targetFileExtension;
}

Check the $TYPO3_CONF_VARS[GFX][thumbnails_png] setting through install tool. 通过安装工具检查$TYPO3_CONF_VARS[GFX][thumbnails_png]设置。 There are various options how to convert different formats when resizing images. 调整图像大小时,有多种方法可以转换不同的格式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM