Imagemagick convert command: set delay time for the last frame

imagemagick

I have some .png files named '_tmp*.png' and I want to convert them into a gif file by the convert command with imagemagick. So i could use

convert -delay 20 _tmp*.png result.gif

However I want the last frame to hold for a while on screen so that one can see the ending of the animation more clearly. Say, I want the last frame to last for 3 seconds while keeping the delay time for the other frames not changed. I studied the document for the convert command but it seems it does not have such a choice.

So how can I do this with the convert command?

Best Answer

You can do it like this:

convert -delay 40 {1..9}.png -delay 300 10.png -delay 40 {11..14}.png animated.gif 

enter image description here

Basically, you set the delay just before the image you want it to affect and it stays set until you change it.

If you want to set a variable delay, so that the first (i.e. black here) and the last frame (i.e. yellow here) are displayed longer, you can do this:

convert -size 300x200 xc:black xc:red xc:lime xc:blue xc:cyan xc:magenta xc:yellow -set delay '%[fx:t==(n-1) || t==0 ? 400 : 40]' result.gif

enter image description here