Can you show a static image after several animation loops in a gif?

I have an animated gif that I want to loop n times (animation .gif). After the loop, I want to show a static image (static.gif). The animation will be displayed over the Internet, so the file size should be as small as possible.

I tried to implement it using Imagemagick adding a static image with zero latency ...

convert -loop 3 animated.gif -delay 0 static.gif newanim.gif

      

Although the static image is shown at the end, the problem is that after each iteration, the static.gif is displayed for a second.

Another thing I tried was adding animation 3 times and static image at the end. This works great, but the file gets too large, especially if the animation is long and it loops repeatedly. For example, a 6.1mb animation becomes ~ 18mb.

convert -loop 1 animated.gif animated.gif animated.gif static.gif newanim.gif

      

I am using Python on a linux environment to implement this, so if there are programmatic ways to do this instead of Imagemagick, that will work too.

EDIT : I didn't mention the limitation: it should work without any client side programming (Javascript, CSS, etc.). This should be a purely gif solution. This limitation makes it different from How to stop an animated gif from looping

+3


source to share


2 answers


No, you cannot. The GIF animation format does not provide this capability.



There are various ways to do what you want on a web page, but you will need to have a separate file for the static image, and you will need code (like JavaScript or perhaps CSS) to render the static image after the desired number of animation loops.

+5


source


I'm sure your problem with the resulting gif size is what you are using. I created these samples, one with animation and the other with animation repeating 2 times and getting the same size for both. Check it yourself:

single loop two loops



I used ScreenToGif , it is super buggy and only works on Windows but does the job and can open an existing gif or image list for editing.

If you need a Linux solution check out FFmpeg , but I haven't used it myself.

0


source







All Articles