2013-12-29

Don't Kill a Fly with a Cannon—Console Creation of GIF Files

As the saying goes, a picture is worth a thousand words. Some netizens believe that if a picture tells the truth.
If you want to take a screenshot in Linux text mode, you may use fbgrab to get a PNG file (fbcat gives you a PPM file).
If you want to illustrate a process with a series of pictures, then you'll probably need a GIF file. GIMP provides an easy way of creating GIF files by selecting menu items and clicking a few buttons, but for geeks who are used to command line interfaces (CLI), this is not the final answer for them.
With reference to Unix & Linux Stack Exchange question 24014, if your source PNG files are named as [name]%s.png, then the right command is:
$ convert $(for ((a=0; a<700; a++)); do printf -- "-delay 10 [name]%s.png " $a; done;) [result].gif
# `-delay 10' means that each image is displayed for 0.1s.
# [name]: file name of the source PNG files without the ordinal number.
# `%s': the n-th PNG file.
# [result]: file name of the target GIF file.
Without the whitespace between png and the ending ", things won't work.
If the GIF animation has not been finished and intermediate files need to be saved, don't use the .gif format, use .miff instead. [1]

Reference:
[1]: http://www.imagemagick.org/Usage/anim_basics/#gif_anim

No comments:

Post a Comment