resize animated gif

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
enginev

resize animated gif

Post by enginev »

Does anyone knows how I can resize an animated gif file without destroy the animation?

Thanks in advanced for your help
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: resize animated gif

Post by anthony »

That is next to imposible when the animation contains transparency. It is also difficult if the animation does not contain transparency.

See the existing notes on this in IM examples
http://www.imagemagick.org/Usage/animations/#resize

generally the best trechnique, is to coalesce (de-optimize) the animation, then do though a complete re-optimization sequence. That is NOT just frame optimization, but also color optimization too. IM Examples has frame optimization notes complete, but color optimization still needs a lot more work http://www.imagemagick.org/Usage/anim_opt/

In short... There is no easy solution
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
enginev

Re: resize animated gif

Post by enginev »

thanks a lot for the help I really apriciated !!
I found a semi solution to do that cheers ;)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: resize animated gif

Post by anthony »

What was your ''Semi-solution''.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: resize animated gif

Post by anthony »

That de-optimizes and resizes the animation, but does not re-optimize the animation afterwards. It is a reasonable general solution.

It will however fail badly for animations with transparencys as the GIF format can not handle semi-transparent pixels that resize creates. IM just defaults to a 50% transparency threshold which appears to be a universal default for image editors.

This is transparency problem, is especially bad for very thin lines with transparency on both sides.

The best idea is to 'flatten' the animation to a solid color background for GIF animation thumbnails. That way you do not loss 'anti-aliasing' of edges in resized images. Flattening can be done either before or afetr the resize. Most GIF animation websites do it this way.

Finally use the -layers 'optimize' to re-add frame optimization to resuce file sizes further (if posible).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply