Page 1 of 1

Add image to end of gif

Posted: 2015-05-26T11:41:19-07:00
by rabelcher22
I need help or a nudge in the right direction. I am trying to take a gif (animated.gif) and add an image (extra.png) to the end of that gif. What command am I looking for? Any help would be great.

Re: Add image to end of gif

Posted: 2015-05-26T11:55:53-07:00
by rabelcher22
I think I figured it out after having an epiphany.

I just used to convert command.

convert -delay 50 @fileList.txt animated.gif where fileList contains the lines

animated.gif
extra.png

Is this the most efficient way to do this?

Re: Add image to end of gif

Posted: 2015-05-26T12:03:47-07:00
by snibgo
You can do it more directly:

Code: Select all

convert -delay 50 animated.gif extra.png animated.gif
This reads in all the frames in animated.gif. Then it reads the image in extra.png. Then it writes all the images to animated.gif.

When testing, you should write to a different filename, eg animated2.gif.

Re: Add image to end of gif

Posted: 2015-05-26T12:08:50-07:00
by rabelcher22
Thank you for the testing advice. Do you know if this method I came to is the best way to do the action?

Re: Add image to end of gif

Posted: 2015-05-26T12:31:29-07:00
by snibgo
In ImageMagick, it's the only way (as far as I know).

You might need an extra step. Many animated GIFs are optimized, which means each frame stores only the difference from the previous frame. So it is generally better to do this:

Code: Select all

convert -delay 50 animated.gif -layers coalesce extra.png animated.gif
"-layers coalesce" makes each image the full picture, rather than just the pixels that have changed. You might want to optimise the result:

Code: Select all

convert -delay 50 animated.gif -layers coalesce extra.png -layers optimize animated.gif

Re: Add image to end of gif

Posted: 2015-05-26T13:12:58-07:00
by rabelcher22
Thank you for all of the help!