Send Close Add comments: (status displays here)
Got it!  This site "www.robinsnyder.com" uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.  Note: This appears on each machine/browser from which this site is accessed.
Python: Image animation using PIL
by RS  admin@robinsnyder.com : 1024 x 640


1. Python: Image animation using PIL
One way to achieve an image animation is to generate a series of images and then combine them into an image format that supports animation.

One such format is an animated gif Image file.

The Python PIL library supports this. This page looks at using 3D images created using matplotlib and creating an animated GIF (Graphics Interchange Format) image.

2. Animated Pentagram
Here is an animation of a pentagram, which has embedded Golden Ratio's and was studied by Pythagoras. Animated pentagram

3. Images
Pentagram imagesHere is an image of the 36 images generated with a bounding box around each one. A clipping path is used to capture just the part needed for an image.

4. Static image
Here is a static image. Static pentagramNote that there are two cycles in the flipping and that the progression is geometric and not linear. This is needed so that the animation appears smooth and continuous.

5. Images
In Python, the PIL (Python Imaging Library) can be used to create animations.

The images used are from the code creating images in Matplotlib: 3D plots .

6. Program
Here is the Python code [#1]

Here is the output of the Python code.


7. Animated image
Here is the animated image. Animated image

8. Tweaks
Note the following. One simple way to vary the length of one frame is to just repeat that frame more than once. The GIF specification permits fine-grained control but not necessarily the API to create the animated image.

9. End of page

by RS  admin@robinsnyder.com : 1024 x 640