TYPO3 FileReference converts tiff and bmp to gif
<p>Uploading and using tiff or bmp files in TYPO3 and including them via f:image results them in beeing converted into gif files. Im using 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. Any ideas how to configure typo3 to convert tiff and bmp into jpg and not gif? Can't imagine that this is the right behavior.</p>

<p>edit:</p>

<p>i found out that the decision for the output format is done at </p>

<pre><code>TYPO3\CMS\Core\Resource\Processing\AbstractGraphicalTask::determineTargetFileExtension
</code></pre>

<p>If there is no configuration given it will use gif or png for all non-jpg images. I overloaded the </p>

<pre><code>\TYPO3\CMS\Core\Resource\Processing\ImageCropScaleMaskTask 
</code></pre>

<p>which extends the AbstractGraphicalTask and rewrote the function to properly convert bmp and tiff.</p>

<p>Overwrite the default fal config in ext_localconf.php</p>

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

<p>New function:</p>

<pre><code>protected function determineTargetFileExtension() {

    if (!empty($this-&gt;configuration['fileExtension'])) {
        $targetFileExtension = $this-&gt;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-&gt;getSourceFile()-&gt;getExtension() === 'jpg' || $this-&gt;getSourceFile()-&gt;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-&gt;getSourceFile()-&gt;getExtension() === 'png') {
                $targetFileExtension = 'png';
            } elseif($this-&gt;getSourceFile()-&gt;getExtension() === 'tif' || $this-&gt;getSourceFile()-&gt;getExtension() === 'tiff' || $this-&gt;getSourceFile()-&gt;getExtension() === 'bmp') {
                $targetFileExtension = 'jpg';
            } else {
                // thumbnails_png is "0"
                $targetFileExtension = 'gif';
            }
        }
    }

    return $targetFileExtension;
}
</code></pre>