Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create animated gif from a set of jpeg images

I need something that can be scripted on windows 7. This image will be used in banners.

like image 817
Cbox Avatar asked Sep 10 '10 22:09

Cbox


People also ask

How do I make multiple jpegs into one GIF?

To do this, select File > Scripts > Load Files into Stack. A pop up window will appear that allows you to choose the GIF folder that you created in Step One. Click Browse to select and open your images and then click OK. Photoshop will create a new file with all of your images layered on top of each other.

How do I turn a group of pictures into a GIF?

If you use Google Photos on Android (or iOS), you can make an animated GIF from a selection of your pictures. Just tap Library, then Utilities and Create New. Choose Animation, select the photos and tap Create.

Can JPEG files be animated?

No, the JPEG file format has no inherent support for animation.


1 Answers

Simon P Stevens' answer almost got me there:

ffmpeg -f image2 -i image%d.jpg video.avi ffmpeg -i video.avi -pix_fmt rgb24 -loop_output 0 out.gif 

Let's see if we can neaten this up.

Going via an avi is unnecessary. A -pix_fmt of rgb24 is invalid, and the -loop_output option prevents looping, which I don't want. We get:

ffmpeg -f image2 -i image%d.jpg out.gif 

My input pictures are labeled with a zero-padded 3-digit number and I have 30 of them (image_001.jpg, image_002.jpg, ...), so I need to fix the format specifier

ffmpeg -f image2 -i image_%003d.jpg out.gif 

My input pictures are from my phone camera, they are way too big! I need to scale them down.

ffmpeg -f image2 -i image_%003d.jpg -vf scale=531x299 out.gif 

I also need to rotate them 90 degrees clockwise

ffmpeg -f image2 -i image_%003d.jpg -vf scale=531x299,transpose=1 out.gif 

This gif will play with zero delay between frames, which is probably not what we want. Specify the framerate of the input images

ffmpeg -f image2 -framerate 9 -i image_%003d.jpg -vf scale=531x299,transpose=1 out.gif 

The image is just a tad too big, so I'll crop out 100 pixels of sky. The transpose makes this tricky, I use the post-rotated x and y values:

ffmpeg -f image2 -framerate 9 -i image_%003d.jpg -vf scale=531x299,transpose=1,crop=299,431,0,100 out.gif 

The final result - I get to share my mate's awesome facial expression with the world:

Example of an animated gif created with ffmpeg

like image 51
dwurf Avatar answered Oct 15 '22 11:10

dwurf