Bug #43624


Gifbuilder cannot generate images

Added by torsten wolter over 11 years ago. Updated over 6 years ago.

Should have
Image Cropping
Target version:
Start date:
Due date:
% Done:


Estimated time:
TYPO3 Version:
PHP Version:
Is Regression:
Sprint Focus:


Gifbuilder does not render images correctly. This problem happens no matter if Gifbuilder is used from extensions or from TypoScript (for an example with pure TypoScript see note #2).

The problem happens, if the input image has another file type, than the type, which TYPO3 uses internally.

The result are broken output images.


Source im My Extension to create small Image

$imgConfig = array();
$imgConfig['file'] = 'GIFBUILDER';
$imgConfig['file.']['XY'] =$w.','.$h;
$imgConfig['file.']['backColor'] ='#ff0000';
$imgConfig['file.']['transparentColor'] ='#000000';
$imgConfig['file.']['10'] ='IMAGE';
$imgConfig['file.']['10.']['file']= 'fileadmin/somefile.jpg'
$bildstring = $this->cObj->IMAGE;

I get a red(!) Picture.

The image somefile.jpg is rendered in one step into the folder typo3temp/_processed_/csm_somefile_hash.jpg
This file is internal a gif or png (as it is set in the config of typo3)

Later in core/Classes/Imaging/GraphicalFunction.php the imageCreateFromFile function tries to work with the file and uses the fileextension
In my case Extension = jpg and mimetype = png

The function called imagecreatefromjpeg and gets an empty result

Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #46866: wrong image extensionsClosed2013-04-02

Related to TYPO3 Core - Bug #46530: Crop-Scaled images have wrong file content typeClosed2013-03-292013-03-29

Actions #1

Updated by Gisèle Wendl over 11 years ago

Hi Torsten,

just had the same issue so I made a change to following function imageCreateFromFile

public function imageCreateFromFile($sourceImg) {
        $imgInf = pathinfo($sourceImg);
        $ext = strtolower($imgInf['extension']);
        list($width, $height, $typeimg, $attr) = getimagesize($sourceImg);
        if (isset($typeimg) && in_array($typeimg, array(IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF, IMAGETYPE_WBMP))) {
            if ($typeimg==3) {
            } elseif ($typeimg==2) {
            }elseif ($typeimg==1) {
            }elseif ($typeimg==4) {
            }else  {
                return false;
        } else  {
            return false;
        switch ($ext) {
        case 'gif':
            if (function_exists('imagecreatefromgif')) {
                return imageCreateFromGif($sourceImg);
        case 'png':
            if (function_exists('imagecreatefrompng')) {
                $imageHandle = imageCreateFromPng($sourceImg);
                if ($this->saveAlphaLayer) {
                    imagesavealpha($imageHandle, TRUE);
                return $imageHandle;
        case 'jpg':
            if (function_exists('imagecreatefromjpeg')) {

                return imageCreateFromJpeg($sourceImg);
        case 'jpeg':
            if (function_exists('imagecreatefromjpeg')) {

                return imageCreateFromJpeg($sourceImg);
        // If non of the above:
        $i = @getimagesize($sourceImg);
        $im = imagecreatetruecolor($i[0], $i[1]);
        $Bcolor = ImageColorAllocate($im, 128, 128, 128);
        ImageFilledRectangle($im, 0, 0, $i[0], $i[1], $Bcolor);
        return $im;


This makes it bit more bullet proof for the problem of mixed-up file-extensions

Actions #2

Updated by Tobias Liebig over 11 years ago

  • Category set to Image Cropping
  • Complexity set to medium

This does not only happen in extensions, but also in TypoScript:

page.20 = IMAGE
page.20.file = GIFBUILDER
page.20.file {
  XY = 100,100
  backColor = #ff0000
  transparentColor = #000000
  10 = IMAGE
  10.file = fileadmin/somefile.jpg
  10.file.maxW = 100
  10.file.maxH = 100

The problem is that, while processing the Image (\TYPO3\CMS\Core\Resource\ProcessedFile) it gets cached as file with '.jpg', containing GIF-data, so the file extension should be ".gif" instead.
Gisèles fix looks good (makes imageCreateFromFile not relying on the file extension), but I think this issue must be solved one step before, when processing and caching the file.

Actions #3

Updated by B. Kausch over 11 years ago

  • Target version set to 6.0.5

Should be fixed ASAP.

Actions #4

Updated by Frank Krüger about 11 years ago

B. Kausch wrote:

Should be fixed ASAP.

This have to be fixed now, this is a massive bug if upgrading existing installations to 6.0.x!
Gisèles fix works!

Cheers Frank

Actions #5

Updated by Chris topher about 11 years ago

  • Subject changed from Problems generating images with gifbuilder in extensions in Typo3 6.0 rc2 to Gifbuilder cannot generate images
Actions #6

Updated by Andreas Keck about 11 years ago

Same Problem with this TypoScript if input image is not png

  10 {  
    file = GIFBUILDER
    file {
      XY = 130,230
      format = png
      quality = 100
      transparentBackground = 1
      10 = IMAGE
      10 {
        file {
 = page:tx_akstatements_pimage
          import = uploads/tx_akstatements/
          width = 130c
          height = 230c
        #mask = fileadmin/templates/kv/img/maske_anja-bild.png
    stdWrap.wrap = <div id="anja-box" style="background-image:url(|);">
Actions #7

Updated by Felix Kopp about 11 years ago

Could you please check if this error can be reproduced with 6.0.5rc1

Thank you!

Actions #8

Updated by B. Kausch about 11 years ago

6.0.5rc1 is functioning for me!

Actions #9

Updated by Christian Kuhn about 11 years ago

  • Status changed from New to Resolved

Solved in young core versions

Actions #10

Updated by Riccardo De Contardi over 6 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF