SmileyChris/easy-thumbnails — pull request #217 by anvio (2013-04-04 06:57:10+00:00)
Title: Support for animated GIF images

Hi Chris,

After a long long night I finally managed to add support for animated GIF images to easy-thumbnails.

It uses images2gif.py to extract all frames as PIL images. These frame images get processed by the thumbnail processors like every other still image. After they have been processed they get merged into one animated GIF (see Thumbnailer.generate_thumbnail).

Some animated GIFs react very badly to "resample=Image.ANTIALIAS" when resized. Therefore, I had to add a new "resample" kwarg to the default scale_and_crop processor (see easy_thumbnails/processors.py:158). This kwarg can be used to override the default behavior of Image.ANTIALIAS to Image.NEAREST. The NEAREST resample mode gets set explicitly when a GIF is getting processed (see easy_thumbnails/files.py:301). The downside is that resized GIFs do not have the best quality but the compatibility is improved. Maybe this is something that the user can specify in the Django settings (quality or compatibility)?

I thought this feature would be nice to have in the official version of easy-thumbnails. So feel free to add it! If you have any questions, do not hesitate to contact me!

Cheers
Pascal