Dynamic avatars on Twitter
The visualization tells me that the first publication from my Twitter bot, created to dynamically update my avatars daily was 20 December 2012. My bot was a simple Python script that generated images in binary to represent the day of the month.

Why?
Well, doesn’t it get a little boring looking at the same thing every day?
Lets look at the details below.
My script worked in concert with PythonAnywhere.com which provided a free hosted Python environment and scheduled execution of Python tasks, e.g. 00:05UTC every day. The script executes and an image is generated by selecting colors randomly from a simple palette painting them onto a canvas.
The shape it paints is a five-bit binary number between one and 31 representing the days of the month. So, for example, if you take the number 29 in binary, you can represent it with five bits, 11101.
Flip it on it’s side into a matrix and you can generate a pattern like follows:
11111 11111 11111 00000 11111
Turn the ones into colors and the zeros black and you can create some nice ever-varying images:

These images are created from the original code that ran from 20 December 2012 to 29 November 2014.

Automation doesn’t always run perfectly
A single hope was that I’d generate a perfect set of 365 days of avatar images and probably leave it there as a completed project. I’m might want to create a GIF but beyond that I had no real plans.
The first tranche of images didn’t materialize. Sometime around April 2013 I noticed images were no longer being created on my host, and as such, my Twitter profile wasn’t being updated. I noticed it again in July that same year.
The cause was infrastructure maintenance at pythonanywhere.com, although I can’t remember if it was related to the Python Imaging Library, or the Twitter API Library I was using. As the error wasn’t noticed soon enough the continuity in image generation was broken.
Both times, before I could fix the issues myself the code started working again, presumably after the hosting provider finished its own maintenance.
Breaking changes
Eventually the Twitter API Library used by Python Anywhere introduced a small but subtle breaking change seen in this diff. The code simply needed the addition of a parameter _base64=True to work again. The API had changed the assumption that image data would be encoded as base64 when supplied to the function, which would then be encoded into a URL for the call to the Twitter API. A subtle but ultimately breaking change.
The distribution of the code made it difficult to debug and I had to go into the locally installed package files i.e. /usr/local/lib/python2.7/dist-packages/twitter/api.py where I was able to find the issue.
All very hair pulling, but at least it works now. Also, the effort gave me pause, and so I decided to use some of the unintended momentum of the weekend debugging to create something new.
Out of adversity…
I decided it was time to re-engineer the code. With the fix complete I decided to add a little sophistication to its output.
In June 2014 The National Library of New Zealand (NLNZ) released a blog on Heritage Colour Palettes. Sets of color palettes inspired by heritage objects in the national library; primarily the colors we see on the pages of books or their bindings.

Finding color palettes was an issue I had when first creating the code. All the potential colors, all the potential configurations. I didn’t really know how to approach it and so I just chose primary colors.
This first set of NLNZ palettes now gave me a number of more attractive options intersecting a few of my interests.
Beyond palettes I wanted to change the design of the images. While I still wanted to create a binary representation of the day of the month I wanted to add more complexity to the stripes. Adding more stripes would create more variations in the images that would be created on any given day. The pattern may even start to look like wallpaper, in homage to Birgit Bachler’s Big Data Wallpapers in her Copy Wildly series. Who knows, maybe my binary numbers patterns could be enlarged and put on display in a domestic setting one day?!
I stabilized the API library code on the server by uploading my own static copy and the routines I am using have been made a bit more flexible for other purposes in the future.
The first two images have even already been published!

Let’s see the kinds of images we can create with color and lines this time around.
Additional
The code is available on GitHub:
The Python Anywhere hosting is no longer maintained, but you can see snapshots on the Internet Archive:
Archived Images are available on GitHub:
Heritage color palettes by NLNZ:
Addendum
A friend noticed that the output bears similarities to Cory Arcangel’s 2006 work Colors which is a nice synchronicity:
![]()

4 thoughts on “Dynamic avatars on Twitter”