Creating a GIF animation from PNG files

  • Is there a tool to create a gif animation from a set of png files?

    I tried the convert command from the ImageMagick suite, but this doesn't always succeed. Also, I have several issues with this:

    1. I can't tell what the progress is.
    2. No matter what I try, the -delay flag doesn't change the frame rate of the gif animation.
    3. convert determines the frame order based upon the alphabetical order of the files names. This means that name500.png will be placed right after name50.png and not after name450.png I can fix this by adding 0's but this is annoying.

    Regarding item 3., you can still use `convert` after sorting the files. Probably, something like this works `files=$(ls name*png | sort -n -tname -k1); convert $files animation.gif`

    For Point 1: convert has a `-monitor` parameter that tracks the process

    @hhc - all the categorization is just a link to an answer with 5 links; only one of them seems related, but is just a link to the above question. - A comment by @Luke gives a simple solution: `convert -delay 200 -loop 0 *.jpg output.gif`.

  • nano

    nano Correct answer

    9 years ago

    Newer versions of ffmpeg have no -sameq (see faq) but do have GIF support.

    ffmpeg -i %03d.png output.gif

    Where %03d is the frame ID in 3 digits.

    You may also try to use ffmpeg to create a movie out of a sequence of images and then convert the movie to a GIF animation (again using ffmpeg).

    # cf.
    # first convert an image sequence to a movie
    ffmpeg -sameq -i %03d.jpg output.mp4
    # ... and then convert the movie to a GIF animation
    ffmpeg -i output.mp4 -pix_fmt rgb24 -s qcif -loop_output 0 output.gif

    This instruction is out of date.

    The `sameq` option is not available anymore. Further, for me, this overwrites the original image files and does not produce a valid movie file.

    What's the point of leaving the `-sameq` code there? Why would you even want to use a lossy video format (`output.mp4`) as a temporary? And if so, why "same quality" as the input, instead of very high bitrate? Artifacting from that is just going to make things worse for the GIF encoder. If you did need to use a video as a temporary, you'd want to use something lossless like huffyuv. Or MJPEG with no transcoding, just remux the input jpegs into an MJPEG. (`-codec:video copy`).

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM