Closed (outdated)
Project:
ImageMagick
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
3 Oct 2012 at 20:20 UTC
Updated:
20 Jan 2025 at 16:05 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #1
diwant commentedYes! It worked
Comment #2
diwant commentedWhoops, changed the state.
Comment #3
sunAccording to #1115658-1: Animated GIF image gets broken on resize with ImageMagick toolkit, the -coalesce option breaks animated GIFs. :-/
Instead of $extra, why not add a new ops[] before the existing -resize?
Comment #4
alexku commentedAttached a patch which uses $image->ops[] instead of extra.
Tested with imagemagick (convert). Doesn't work when graphicsmagick (gm).
Comment #5
attiks commented#4 Works for me, tx
Comment #6
andros commentedWonder why this it not allready part of the dev version? Is there a blocker?
Comment #7
nickgs commented#4 worked well for me too. Thanks.
Comment #8
F117 commented#4 confirmed working. :)
Comment #9
elliotttf commentedAnother +1 for me. I had an issue with another patch from the ImageMagick Advanced module, but was able to address that over there: #1883192-11: Option for progressive jpeg.
Comment #10
q11q11 commentedCorrect version of #4
Comment #11
kristofferwiklund commentedPatch in #10 works great. Thanks.
Comment #12
elijah lynnComment #13
klase commentedAlso confirming that patch in #10 works great. Look forward to seeing this in next release!?
Comment #14
elijah lynnAnother confirmation here.
Comment #15
elijah lynnNeeds a space between if and first '('.
Comment #16
tobiberlinConfirming that it works
Comment #17
q11q11 commentedFixed #10 according to coding standards.
Comment #18
elijah lynnThanks q11q11
Comment #19
mbrc commented+1, #17 works for me as well.
Comment #20
ñull commented#17 works for me as well. Please commit to a release version.
Comment #21
scotwith1tThis seems to fix the rendering problem, but if I have a large gif like this

it shortens the animation sequence when it's resized? (Notice how it restarts the animation shortly after the graph overlay shows up, whereas the top full gif shows the full sequence all the way to flipping over the graph)

Is this a function of the file size being shrunk or something?
Comment #22
scotwith1tAny update on this? Hate to patch this module on yet another project for this problem...looks like you guys have been working hard to get a D8 version, so I totally understand, but if we could get this committed and a new release with it in there, I'd be grateful. If we can address my last comment as well, even better!
Comment #23
mondrake@scotself actually it seems there's no one attending at the D7 version of this module lately. I have ported to D8 and am maintaining that version but have no intention to maintain the D7 one - see #2558165: Offering to maintain a 8.x-1.x branch of ImageMagick for details. If anyone is interested to apply for maintainership of the D7 version, details are in the same issue.
Comment #24
howdytom commented#17 works great! Thank you. Scaling GIF animation is working again. Note. If your GIF result still looks weird, make sure to hit „update style“ button in example.com/config/media/image-styles/edit/yourstyles
@mondrake: Please commit the patch to Drupal 7 release.
Comment #25
nico.knaepen commentedWhen is this change going to be commited?
Comment #26
pedrospIn my case patch #17 was not enough, because I wanted to scale, crop or smart crop an animated GIF.
The patch only enhance the resize function with "-coalesce", but as pointed in this stackoverflow answer, we need also to override the crop function.
I have updated the function with this following code and it did the trick for me:
Comment #27
Chris Charlton+1
Comment #28
karlsheaReroll with changes from #26, additionally applying the same changes to
image_imagemagick_resize()Comment #29
rgpublicI've attached patch #28 ported to D8 just in case anyone finds this useful.
Comment #30
jcmartinezI can confirm that #29 worked for me on Drupal 8.
Note that it only works with ImageMagick, but it doesn't work with GraphicsMagick.
Comment #31
asrobUpdated patch to work with 8.x-2.x-dev.
Comment #32
leovw commentedI can confirm that #31 is working for me, thank you for this! Surely this should be added to the Imagemagick module?
Comment #33
mondrakeSorry, not in the 8.x version. Please see #2949193: ImageMagick scale breaks animated gifs (D8) and #2786435: Support '-coalesce' of Animated GIF image files for alternatives.
Moving back to 7.x branch for @Chris Carlton to make a call.
In general - my understanding is that 'coalesce' will boost the size of multiframe images because it resizes all frames to the largest dimensions, losing any optimization that could have been stored in the original image. So if we had this in, someone will be happy for the fit-to-purpose, and someone will be unhappy for the image sizes. At least, one should decide which way to go and in D8 there are alternatives ways to get there without forcing everybody to do the same.
Comment #34
rgpublicHm, I'm not quite sure if you aren't artificially over-complicating things, @mondrake. Yes, coalesce will lose any optimization coming from shrink-to-fit frame sizes, but losing this kind of optimization usually doesn't blow up filesize unreasonably due to GIF's run length encoding. Further ImageMagick processing might even involve other steps than just scaling, so I think it makes sense to re-optimize the final image anyway if you are really trying to achieve top-notch results. You could do this e.g. with the imageapi_optimize module etc. Currently, though, the image is destroyed, so I think in terms of out-of-the-box experience, it should be fixed with this simple fix without losing too much flexibility.
Comment #35
Chris CharltonI'll review for 7.x with a couple of GIFs and report back.
Comment #36
firewaller commented+1
Comment #37
Chris CharltonI remember this working for D7. I'll need to double-check.
Comment #38
auth commentedImagemagick 3.x has removed some functions from ImagemagickToolkit. This is the patch in #31 using arguments() to get and modify arguments.
Comment #39
rgpublicImagemagick *3.x* ? Are you sure? The current version is 7.x! 3.x doesn't exist for decades, I suppose:
https://imagemagick.org/index.php
Comment #40
rgpublicAh, you mean the Drupal module "imagemagick". Sorry for the spam. Understand now.
Comment #41
auth commentedUnderstandable misunderstanding, I could have been more descriptive in my comment.
Here is a retry of a functional patch.
Comment #42
Slimbips commentedis it possible someone applys the patch and uploads it?, i have hard times figuring out how to patch, or nothing happens at all or patch fails all the time
Comment #43
howdytom commentedpatch -p1 < imagemagick-resize_animated_gifs-1802534-41.patchComment #44
Slimbips commentedCool thanks, i guess the patch worked---> https://ibb.co/zHgKDxj
But the animation isnt fixed on my website :(
EDIT: nvm the avatar wasnt going through imagemagick resize, changed in the view to resize and problem solved, thanks!
Comment #45
tostinni commented@Slimbips it may due to the images being already generated in your
sites/default/files/stylesfolder.The radical thing to do to force mass rebuild is to delete this folder (which only contains images generated by images styles, the original are located in
sites/default/files/2021-03...folders).If you have a specific image style that causes problem, you can delete its folder
sites/default/files/styles/IMAGE_STYLE_MACHINE_NAMEDon't forget to do a backup of it ;).
Comment #46
auth commentedAttached is an updated patch that work with the latest version
Comment #47
ipo4ka704 commentedI think needs to move it to new version.
Comment #48
mondrakeNo, it’s fixed in D8 and later, see child issue.
Comment #49
mondrakeDrupal 7 is EOL