Making animated GIFs in Python


This week’s blog post is a quick break from science infographics! I use Python pretty often at work, and recently I’ve also been experimenting with using it for design. For this project I wanted to make a browsable color palette website like Adobe Kuler, but with animated design examples for every color palette.

To do this I first wrote a Python script to make a GIF illustration for any 5-unit color scheme. The script features five different animated patterns, all based on Islamic mosaics. The code isn’t anything fancy - I used the basic Matplotlib graphing library to make each pattern and ImageIO to output images.

Next I picked 50 of my favorite color palettes, most of which were loosely based on popular colors from Kuler and Color Hunt. I decided to stick with only colorblind-friendly color palettes for a more useful and curated project.

I also wrote a script to generate titles for each color scheme. A lot of online color palettes have great names like Cherry Cheesecake, and I wanted to try and automate my own whimsical titles.

For the title generator I made a library of my favorite color names organized by color (pumpkin, cherry, buttermilk), as well as modifier words. Next I specified which two colors were dominant in each color palette, and let my script generate appropriate color scheme names for each entry.

Finally I combined all of the code and fed my list of 50 color palettes into the GIF-and-title maker. The final website randomizes the color schemes in Javascript so that it’s more fun to click through each color palette.

EDIT: I’ve open-sourced the Python code here for anyone interested in the project.