Animation and the command prompt

Python doesn’t seem to have a simple method for creating animated gifs, but other programs can be executed from python.  Here is what I’m using. It is simple and works.

1) install ImageMagick.  There are other programs that can be used to bundle images into a gif but this is the first and only one I’ve tried so far.  I installed: ImageMagick-6.7.3-10-Q8-windows-dll.exe

2) create a folder with sequentially numbered images.

3) Run the ImageMagick convert.exe program from a command prompt or from a python program.

This can be done from the command prompt:

C:\>convert C:\...path...\*.png C:\...path...\animation.gif

“Convert.exe” is the ImageMagick program that can bundle an image series (such as *.png above) into an animated gif file (such as animation.gif above).
The convert program can be executed from within a python program like this:

from subprocess import call

call(r'\Program Files\ImageMagick-6.7.3-Q8\convert.exe ' +
     r'\Python26\Lib\site-packages\xy\images\*.png ' +
     r'\Python26\Lib\site-packages\xy\images\im55.gif' )

You can also pass a list. The first item is the program, followed by a list of arguments:

from subprocess import call

command = [r'\Program Files\ImageMagick-6.7.3-Q8\convert.exe',
           r'\Python26\Lib\site-packages\xy\images\*.png',
           r'\Python26\Lib\site-packages\xy\images\im23.gif']
call(command)

Or:

from subprocess import call

call([r'\Program Files\ImageMagick-6.7.3-Q8\convert.exe',
      r'\Python26\Lib\site-packages\xy\images\*.png',
      r'\Python26\Lib\site-packages\xy\images\im23.gif'])

NOTE: Spaces are needed when passing the command as one string but not needed in the list format. Also note that the complete path for the program is needed when using call() which is not required if you run convert.exe directly at the command prompt.

4) Delete the series of images (if not needed).