ThatsRightJack
ThatsRightJack

Reputation: 751

GIF animation with ImageMagick and many images

I'm trying to create an GIF animation with ImageMagick using multiple source jpg images. Here is the command line call I make

convert -delay 20 -loop 0 $WDir/*.jpg -resize 20% $WDir/animate.gif

where $WDir is a bash variable that points to the working directory where all the images are located. The script runs fine for say 10 images, but I have 500+ images I want to animate. I don't want to resize the images any less and I've tried to limit the memory usage, but that didn't seem to help.

Can someone tell me how I would go about animating a significant amount of images without sacrificing image quality while using a machine with limited RAM (16GB)? If it needs to be done in "chunks", that's fine, as I can write a bash script to do the work and "set it and forget it".

Upvotes: 2

Views: 4761

Answers (1)

fmw42
fmw42

Reputation: 53081

What is your Imagemagick version and what is the platform? I assume Unix (Linux or Mac). What error are you getting? If you are running out of memory, then you can adjust your policy.xml file so that you can use disk rather than RAM, but it will take longer to process. You may need to process in batches as you have said. Also depending upon your OS, the string of image names may exceed an OS limit (typical for Windows).

My suggestion would be to process all the images using mogrify, since it process them one at a time, so no significant RAM usage. Use mogrify to resize and reformat. Once done you can probably load all the gifs into RAM and make the animation. I would suggest you create a new directory to hold the output from mogrify and use the -path argument to specify that output directory. The directory needs to be created first. So

cd to directory holding your input images
mogrify -path yourpath2/newdirectory -format gif -resize 20% *.jpg

Then once that is done

cd to newdirectory
convert -delay 20 *.gif -loop 0 animate.gif

Upvotes: 4

Related Questions