Even though the extension is .jpg the image type is changed to .png. And the file size is subsequently much larger than it should.

As an example you can compare the first image in this page with the same one in the front page slider.

Same image with different imagecache presets, the one using the canvas action is almost 10 times bigger and I am quite concerned about the performance hit this may cause.

Comments

dman’s picture

define_canvas should not be doing any conversion to png! Not unless your imagecache process includes that step deliberately.
Can you show a snapshot of your enabled actions? I'm not sure how to replicate that.

castawaybcn’s picture

StatusFileSize
new24.21 KB
new24.49 KB
new24.83 KB

I don't think I have included any png conversion.
Take a look at the screenshots of the two problematic presets, they are both called depending on the picture's proportions through the "aspect switcher" preset, I am attaching a screenshot of this preset as well.

Thanks a lot for looking into this.

dman’s picture

Indeed, you are quite right.

canvasactions.inc on 6.x-1.x

 275   if ($action['under']) {
 276     $canvas_object = (object) array(
 277       'resource' => $newcanvas,
 278       'info' => array(
 279         'width' => $targetsize['width'],
 280         'height' => $targetsize['height'],
 281         'mime_type' => 'image/png',
 282         'extension' => 'png',
 283       ),
 284       'toolkit' => $image->toolkit,
 285     );

Boo.

6.x-2.x fixed it a while back.
Should be

  if ($action['under']) {
    $canvas_object = (object) array(
      'resource' => $newcanvas,
      'info' => array(
        'width' => $targetsize['width'], 
        'height' => $targetsize['height'],
        'mime_type' => $image->info['mime_type'],
        'extension' => $image->info['extension'],
      ),
      'toolkit' => $image->toolkit,
    );
    imageapi_image_overlay($canvas_object, $image, $targetsize['left'], $targetsize['top'], 100, TRUE);
  } 

Must be about time I pushed 2.x stable, it's got a lot of old stuff that's been tidied up slowly.

castawaybcn’s picture

+1 for 2.x stable ;)
In the meanwhile I will manually edit canvasactions.inc, thanks a lot for the information.

gordon’s picture

Version: 6.x-1.8 » 6.x-2.x-dev
Priority: Normal » Critical
StatusFileSize
new735 bytes

This works great, here is a patch

dman’s picture

Status: Active » Fixed

This fix was in 6.x-2.x already, but unreleased. I've now added a point release 6.x-2.1 to capture this and others.
The patch above has been applied to 6.x-1.9 and a version rolled for it also.
Thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.