Reputation: 5157
I have a bunch of png files named as 1.png, 2.png, etc. and I want to create an animated gif image from them all. I haven't been successful in finding a solution for a terminal command that will convert these png files into a single animated gif.
Can someone post some commands that I can try? I have tried "convert" commands but my terminal always says convert is not found even though I have installed ImageMagik.
Upvotes: 32
Views: 32458
Reputation: 363063
ImageMagick's convert
command (changed to magick
command in IMv7) works perfectly for this but you'll want to list the filenames in the correct order. Using *.png
will jumble frames if the digits don't have the leading zeros because the ordering is alphabetical:
1.png 10.png 11.png 2.png 3.png ...
If you use zsh you can simply use a glob qualifier:
convert *.png(n) out.gif
Otherwise you can sort the ls output
convert $(ls *.png | sort -V) out.gif
If your filenames have leading zeros go ahead and use *.png
. Note that the default delay between frames is small, so depending on your use case the frame rate might be too quick. To change that use the -delay
option, for example:
convert -delay 50 *.png out.gif
This will set FPS to 100/50 = 2 frames per second.
Upvotes: 38
Reputation: 11555
convert *.png screens.gif
This answer suggested installing convert
with brew install ImageMagick
.
Upvotes: 54