image-resizer icon indicating copy to clipboard operation
image-resizer copied to clipboard

Failed to send a GIF file.

Open diegocosta-dev opened this issue 1 year ago • 4 comments

Describe the bug

Is there any way to not transform GIF files?

Some gif files cannot be sent, I will leave the example.gif file to be tested.

example gif

Steps to reproduce

  1. Go to "my-site.ddev/admin/asset"
  2. Upload example.gif

image

Craft CMS version

4.12.7

Plugin version

3.0.12

Multi-site?

No

Additional context

No response

diegocosta-dev avatar Oct 21 '24 23:10 diegocosta-dev

I thought this was supposed to be handled by ImageHelper::canManipulateAsImage, but looks like it isn't.

On the one-hand, I'd want animated GIFs to be left alone, while static GIFs should be processed. I'll look into options on that front. In either scenario, I can't get it to throw an error like that. Are you sure that's coming from Image Resizer? What are your resize limits set to?

Going one step further, I might like to include checkboxes for different file types, as I've been meaning to do for some time. For example, PNGs can often lead to fuzzy images when resized, through no fault of our own (seems an inherent Imagick and GD issue).

engram-design avatar Oct 22 '24 04:10 engram-design

@engram-design Thanks for it.

Yes, This error happens when Image Resizer is enabled in Craft. I tried to check the logs but I didn't find anything.

image

image-resizer.php

<?php

return [
  '*' => [
    'enabled' => true,
    'imageWidth' => 1920,
    'imageHeight' => false,
    'imageQuality' => 100,
    'skipLarger' => true,
    'nonDestructiveResize' => false,

    'assetSourceSettings' => [
      '1' => [
        'enabled' => true,
        'imageWidth' => 1920,
        'imageHeight' => false,
        'imageQuality' => 100,
        'skipLarger' => true,
        'nonDestructiveResize' => false,
      ],
    ],
  ]
];

diegocosta-dev avatar Oct 22 '24 11:10 diegocosta-dev

So looks like Craft actually tries to resize an animated GIF frame-by-frame. I think what we're seeing here is a memory timeout.

I'll look at adding options to disable processing GIFs (or GIF + Animated GIF).

engram-design avatar Oct 23 '24 11:10 engram-design

Thank @engram-design for that.

Just to let you know, I had already disabled the "transformGifs(false)" setting in the Craft CMS configuration file "general.php".

I’d be happy to use the "Image Resizer" again.

diegocosta-dev avatar Oct 23 '24 12:10 diegocosta-dev