Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm running an image collection site www.wonkeypics.com
It's a real simple setup, nothing fancy but imagecache keeps destroying the animated images. Even when nothing needs to be done to them it processes them anyways. How can I make it skip over anything with a .gif file extention?
Thanks :)
Comment | File | Size | Author |
---|---|---|---|
#11 | 1130342-destroys-animated-gifs.patch | 1.66 KB | darkdim |
#3 | imagecache-gif.patch | 1.65 KB | joruffin |
Comments
Comment #1
ghankstef CreditAttribution: ghankstef commentedI am running into this too. I'm going to try to see if there is a way to detect the animated gif. Here is an idea that could be used with theme_imagecache with the idea that you return or skip imagecache if its an animated gif:
http://stackoverflow.com/questions/280658/can-i-detect-animated-gifs-usi...
Comment #2
ShaneOnABike CreditAttribution: ShaneOnABike commentedI was looking for something similiar. I kind of wonder if we couldn't put a patch in theme_imagecache that has a flag (admin) to ignore animated GIFs. Cropping these images completely losses the animation (which makes sense but there's no way around that). This might not be ideal since it does ignore the scaling aspect of things :S
Here's the code for anyone else that needs it.
theme_imagecache
imagecache_is_animated_gif($filename) - new function
Comment #3
joruffin CreditAttribution: joruffin commentedPatch adapted from above code against imagecache 6.x-2.0-beta12.
Comment #4
truyenle CreditAttribution: truyenle commentedSame issue and the patch work for me.
Comment #5
sandrewj CreditAttribution: sandrewj commentedTo me it looks like the patch checks the contents of any file sent to it. Can we add a check at the start that the file is a gif file? This would also avoid the unlikely situation where a PNG or JPG is passed that happens to have the "correct" string. All GIF files start with the string "GIF", supposedly.
Comment #6
sandrewj CreditAttribution: sandrewj commentedLooking into this issue more, it seems like the imagemagic toolkit can support resizing animated gifs. #1115658: Animated GIF image gets broken on resize with ImageMagick toolkit
The proposed patch above would change the default behavior of imagecache. Currently imagecache does its best to generate the altered image or returns a 500 response if unable to. It also returns a 403 response if the file is not registered as an image.
I think it would be ok to return a 500 "internal server error" message if imagecache knows the image won't actually be generated correctly (even though a "valid" image is created) There should be an admin option for marking animated gifs as unsupported in that case.
For the "is_animated" function, I think it should include the filetype check inside the function.
the results should be used in imagecache_create_url to bypass all other work that imagecache would do.
I haven't tested the above code, and I think it isn't an ideal solution, but it would give a more compact solution to the question "how can I make imagecache produce links to the original instead of a derivative when dealing with animated gifs?"
Comment #7
fizk CreditAttribution: fizk commentedPlease reopen if this is still an issue with ImageCache 6.x-2.0-rc1.
Comment #8
tostinni CreditAttribution: tostinni commentedWorking great with RC1, however you have to use imagemagick instead of GD2.
Comment #9
Manuel Garcia CreditAttribution: Manuel Garcia commentedJust confirming that on RC1, using imagemagick the animation is kept, no need to patch anything.
Comment #10
botanic_spark CreditAttribution: botanic_spark commentedI can confirm that imagemagick solves the problem.
Comment #11
darkdimbit corrected code