verbb / image-resizer

A Craft CMS plugin to resize images on upload.
MIT License
128 stars 14 forks source link

Failed to send a GIF file. #86

Open diegocosta-dev opened 1 month ago

diegocosta-dev commented 1 month ago

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

engram-design commented 1 month ago

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).

diegocosta-dev commented 1 month ago

@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,
      ],
    ],
  ]
];
engram-design commented 1 month ago

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).

diegocosta-dev commented 1 month ago

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.