I want make a .gif animated picture from a given set of .jpg pictures.

I would prefer to do it from the command line, so command line tools would be very welcome.

You can use ImageMagick package. Install it using the command:

sudo apt-get install imagemagick

Now you can create a gif from number of pictures(jpg) using:

convert -delay 20 -loop 0 *.jpg myimage.gif
  • 5
    Please, include here how you resize the gif animation etc by 50%. Etc -resize 50%. – Léo Léopold Hertz 준영 Aug 7 '16 at 11:23

To complete @Maythux answer:

To avoid generating a very large file, you can use -resize option:

In my case, I have 4608x3456 images and the generated gif was more than 300M for 32 images

convert -resize 20% -delay 20 -loop 0 *.jpg myimage.gif

or

convert -resize 768x576 -delay 20 -loop 0 *.jpg myimage.gif

Take care of *.jpg

*.jpg sucks a bit when dealing with numeric values, you may generate a gif with unsorted pics.

$ ls|cat
21-33-26_1.jpg
21-33-26_10.jpg   // <--- this one
21-33-26_2.jpg
21-33-26_3.jpg
21-33-26_4.jpg
21-33-26_5.jpg
21-33-26_6.jpg
21-33-26_7.jpg
21-33-26_8.jpg
21-33-26_9.jpg
21-33-28_1.jpg    // <--- should be here    
21-33-28_2.jpg
21-33-28_3.jpg
...

As the shots were taken very quickly (10/s) they all have the same modification time and you can't trick using ls -t for example. On ubuntu you can use ls -v instead, something like:

convert -resize 768x576 -delay 20 -loop 0 `ls -v` myimage.gif

Sorting numerically is quite tricky on Mac OS X though, I guess you'll need to build a custom script.

  • 2
    You can avoid your *.jpg issue by forward padding numbers with zeros. "01.jpg" instead of "1.jpg", and so on. If you get to triple digits, then "001.jpg", "010.jpg", etc. – bigreddmachine Nov 28 '16 at 23:53
  • 1
    There are several ways around the filename sequence problem. Including find, sort, brace expansion, and so on. The ls tool is notoriously unsuitable for this kind of thing. Use find. There's a bit of a learning curve, but it's worth it. – tjt263 Jan 23 '17 at 16:28
  • Some users might be interested in editing filenames with massren: github.com/laurent22/massren – Graham P Heath Nov 30 '17 at 22:09

I don't have enough reputation to comment but instead of modifying file names you can use globbing to get your shell to expand file names

convert -resize 50% -delay 10 -loop 0 image_{0..99}.jpg output.gif

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.