I have a set of about 500 JPEG images. The collective size of the set is about 60 MB and each image has the dimensions 480 x 270. I want to convert these images to an animated GIF.

I have attempted to convert these images to animated GIF in the following way on my i7 system with 16 GB of RAM:

convert -delay 5 -loop 0 -layers optimize -limit memory 64 *.jpg output.gif

However, when I do this, so much of the system resources are taken up that the system becomes unusable and grinds to a halt.

So, what would be a good way to make an animated GIF on Ubuntu?

  • 1
    Did you try - ubuntuforums.org/showthread.php?t=1034104? – Raphael Nov 8 '15 at 9:20
  • Isn't this already here: askubuntu.com/questions/695282/… ? – DK Bose Nov 8 '15 at 10:24
  • @Raphael Thanks for your suggestion of reducing the frame image sizes. It could be useful in some cases, but, for my purposes, the resources consumed were far too great. I gave a solution here that involves the use of some ImageMagick environment variables. – d3pd Nov 9 '15 at 13:17
  • @DKBose This question is a general request for guidance on approaches to make animated GIFs in Ubuntu, whereas that question is specifically about ImageMagick system resource management. – d3pd Nov 9 '15 at 13:21

The following procedure prevents ImageMagick from consuming excessive system resources. It has been tested with ImageMagick 6.8.9-9 on Ubuntu 15.04. To illustrate the procedure, I use the example of converting a video to an animated GIF.

Set up ImageMagick such that it doesn't consume excessive system resources:

export MAGICK_MAP_LIMIT=1024
export MAGICK_TMPDIR=/home/user/tmp

The environment variable MAGICK_THREAD_LIMIT limits the number of threads used by ImageMagick (when it is built with OpenMP enabled). The environment variable MAGICK_TMPDIR is a path to a directory at which ImageMagick can store temporary files. It is particularly useful for frame images of relatively large size because it avoids excessive RAM memory usage.

Prepare the input filename, the output filename and the directory at which frame images are to be stored.


Convert the video to a number of frame images (setting the time limits as appropriate; in this example, from 0 seconds to 30 seconds).

mplayer -ao null -ss 0:00:00 -endpos 30 "${filename1}" -vo jpeg:outdir="${directoryName1}":quality=100

If reasonable for output file size constraints, reduce the size of the video frames (in this example, by 50%).

mogrify -resize 50% "${directoryName1}"/*.jpg

Use ImageMagick to convert the frame images to an animated GIF.

convert -delay 5 -loop 0 -layers optimize -limit memory 64 "${directoryName1}"/*.jpg "${filename2}"

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.