How to speed up creation of animated GIFs
Posted: 2012-01-09T10:10:45-07:00
Years ago (~2006) I created an app w/ Magick++ that created animated GIFs and it worked well.
I've rebuilt it yesterday (no code change) and it runs much slower: it used to take a couple seconds, now takes over a minute. The OS is mostly the same (Gentoo Linux, so many updates since 2006, including the ImageMagick version). My hardware has gotten better since 2006 (faster CPU & more memory). Version: ImageMagick 6.7.1-0 2011-11-02 Q16; OpenMP is enabled.
The animated GIF uses transparency, contains relatively simplistic content (lines & squares, a handful of colors), 100+ generally small frames (10-15 pixels in each dimension).
If I write to a PNG (for example), ImageMagick creates a file for each frame extremely fast (a fraction of a second) which is interesting considering it's actually writing each frame to a separate file on disk. I also see that most of the time is spent in the call to writeImages.
I looked around the message board and found several suggestions. I've tried disabling transparency, setting the tree depth (using quantizeTreeDepth(4) ), the number of colors (using quantizeColors(64) ), and dithering (using quantizeDither(true) ) on all frames but none of these options (even all together) made any practical difference in the time it takes to generate the animated GIF.
I read several statements that ImageMagick uses "a sophisticated color reduction algorithm (see http://www.imagemagick.org/script/quantize.php) which looks for an optimal color palette to best represent the colors in a GIF animation sequence" so I tried specifying that the image should use a color pallete (using classType(PseudoClass) ) but that just slowed down the creation of each frame.
If the color reduction algorithm is the cause, can I turn that feature off?
Are there any other ways to speed up the generation of animated GIFs?
I've rebuilt it yesterday (no code change) and it runs much slower: it used to take a couple seconds, now takes over a minute. The OS is mostly the same (Gentoo Linux, so many updates since 2006, including the ImageMagick version). My hardware has gotten better since 2006 (faster CPU & more memory). Version: ImageMagick 6.7.1-0 2011-11-02 Q16; OpenMP is enabled.
The animated GIF uses transparency, contains relatively simplistic content (lines & squares, a handful of colors), 100+ generally small frames (10-15 pixels in each dimension).
If I write to a PNG (for example), ImageMagick creates a file for each frame extremely fast (a fraction of a second) which is interesting considering it's actually writing each frame to a separate file on disk. I also see that most of the time is spent in the call to writeImages.
I looked around the message board and found several suggestions. I've tried disabling transparency, setting the tree depth (using quantizeTreeDepth(4) ), the number of colors (using quantizeColors(64) ), and dithering (using quantizeDither(true) ) on all frames but none of these options (even all together) made any practical difference in the time it takes to generate the animated GIF.
I read several statements that ImageMagick uses "a sophisticated color reduction algorithm (see http://www.imagemagick.org/script/quantize.php) which looks for an optimal color palette to best represent the colors in a GIF animation sequence" so I tried specifying that the image should use a color pallete (using classType(PseudoClass) ) but that just slowed down the creation of each frame.
If the color reduction algorithm is the cause, can I turn that feature off?
Are there any other ways to speed up the generation of animated GIFs?