GIF disposal previous glitches on looping?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
fraz
Posts: 7
Joined: 2018-04-01T05:44:25-07:00
Authentication code: 1152

GIF disposal previous glitches on looping?

Post by fraz »

I'm try to optimise a radar looping GIF by using a static background and transparent animated layers.
But the loop flickers on restarting since the first frame is the background, and there's no radar image.

Here's the (suboptimal) optimised version. Only 192KB. But it shows a blank background frame before the animation of radar images that makes it flicker.

Code: Select all

convert invert.locations.png \
       -dispose previous -delay 10 -loop 0\
      *-recent.png /var/www/html/radar.gif
Image

Here's the unoptimised GIF with a complex background. it is 1.7MB (sorry!), but loops smoothly because every frame has the complete image without transparency.

Code: Select all

convert -delay 10 -loop 0  *-recent.png /var/www/html/radar.gif
Image

Any ideas?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: GIF disposal previous glitches on looping?

Post by snibgo »

You show two different gifs but not the sources *-recent.png and invert.locations.png, so it's hard to comment.

The general technique, as you seem to realise, is to create a series of frames where every frame is as you want it to be seen. Then "-layers optimize". Your first command doesn't do this.

You probably need to start with a "-layers composite" to combine each *-recent with invert.locations.png. That gives you all the frames for the gif.
snibgo's IM pages: im.snibgo.com
fraz
Posts: 7
Joined: 2018-04-01T05:44:25-07:00
Authentication code: 1152

Re: GIF disposal previous glitches on looping?

Post by fraz »

I think the solution you are describing is actually what the 2nd GIF is, and how I started getting enormous GIF sizes.
Every frame is the complete image including the topography and everything, and doesn't use frame disposal previous.

For my attempt at optimising it:
the background image is: invert.background.png
Image

and *-recent.png is just the last 2 hours of radar images with observations on transparency:
Image
These files then make up the animation with "dispose previous".
fraz
Posts: 7
Joined: 2018-04-01T05:44:25-07:00
Authentication code: 1152

Re: GIF disposal previous glitches on looping?

Post by fraz »

Ah HA!

So I don't need to worry about the disposal method at all.

I just added "-layers optimize" as the last thing and my file has gone from 1.2MB to 285K. And it loops without glitching once I ignore my background approach. It does take my poor raspberry pi zero nearly 3 minutes to make it, but oh well.
Thanks!
Post Reply