Page 1 of 1

Resizing certain GIFs produces incorrect output

Posted: 2014-11-24T17:24:34-07:00
by quuxman
Resizing GIFs where each frame is the size of the whole gif works fine.

However, if frames are smaller and have an offset, the offset is not resized, such that these frames appear in the wrong place.

I'd be happy for my team to work on this if I could get some direction on where the bug probably is in the code. I've never poked around ImageMagick source. We really need this to work correctly :-).

Re: Resizing certain GIFs produces incorrect output

Posted: 2014-11-24T17:44:52-07:00
by fmw42
Have you tried doing something like

Code: Select all

convert animation.gif -coalesce -resize XX -layers Optimize newanimation.gif
see
http://www.imagemagick.org/Usage/anim_opt/#optframe
http://www.imagemagick.org/script/comma ... php#layers

Re: Resizing certain GIFs produces incorrect output

Posted: 2014-11-24T18:04:10-07:00
by quuxman
Doesn't -coalesce remove the offset optimization? That defeats the purpose of resampling (reducing bandwidth usage), and IIRC, didn't work completely either.

Re: Resizing certain GIFs produces incorrect output

Posted: 2014-11-24T18:04:33-07:00
by quuxman
Doesn't -coalesce remove the offset optimization? That defeats the purpose of resampling (reducing bandwidth usage), and IIRC, didn't work completely either.

Re: Resizing certain GIFs produces incorrect output

Posted: 2014-11-24T18:12:20-07:00
by fmw42
I am not an expert on animations, but I was under the impression that the -layers optimize reverses the coalesce and gets you back to your original size and offset, or at least, a trim back to smaller sizes maintaining that offset. see the example at http://www.imagemagick.org/Usage/anim_opt/#optframe

What version of IM and platform are you using?

Re: Resizing certain GIFs produces incorrect output

Posted: 2014-11-24T18:30:07-07:00
by quuxman
Hm, that does indeed work, thanks! It still does increase the size by about 35% in my particular test case if it's the same size, but it's still worth it when resampling to half the width

Re: Resizing certain GIFs produces incorrect output

Posted: 2014-11-24T18:42:14-07:00
by quuxman
Interesting: using the same arguments you suggested with mogrify results in the same bug as frames having the unresized offset, but convert works. I'm using Ubuntu 14.04 BTW, and Version: ImageMagick 6.7.7-10 2014-03-06 Q16

Re: Resizing certain GIFs produces incorrect output

Posted: 2014-11-24T19:52:41-07:00
by fmw42
IM 6.7.7-10 is very old, about 120 versions old. You might benefit from an upgrade. Nevertheless, mogrify is not as full functioning as convert. So your results are not surprising. If your animation is not too large and not proprietary, you might upload it to some free hosting service such as dropbox.com and put a link here. We could then see if there is any further size reduction on a more current version of IM.

You might also try one of the non-IM tools such as listed at http://www.imagemagick.org/Usage/formats/#gif_non-im to see if you can further reduce the size.

See also http://www.imagemagick.org/Usage/anim_opt/#compress_opt for non-IM optimization

See also http://www.imagemagick.org/Usage/anim_opt/#removedups for removing duplicate frames