Resizing certain GIFs produces incorrect output

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
quuxman
Posts: 5
Joined: 2014-11-24T17:19:39-07:00
Authentication code: 6789

Resizing certain GIFs produces incorrect output

Post 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 :-).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Resizing certain GIFs produces incorrect output

Post 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
quuxman
Posts: 5
Joined: 2014-11-24T17:19:39-07:00
Authentication code: 6789

Re: Resizing certain GIFs produces incorrect output

Post 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.
quuxman
Posts: 5
Joined: 2014-11-24T17:19:39-07:00
Authentication code: 6789

Re: Resizing certain GIFs produces incorrect output

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Resizing certain GIFs produces incorrect output

Post 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?
quuxman
Posts: 5
Joined: 2014-11-24T17:19:39-07:00
Authentication code: 6789

Re: Resizing certain GIFs produces incorrect output

Post 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
quuxman
Posts: 5
Joined: 2014-11-24T17:19:39-07:00
Authentication code: 6789

Re: Resizing certain GIFs produces incorrect output

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Resizing certain GIFs produces incorrect output

Post 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
Post Reply