Ashley Sheridan​

Queens Diamond Jubilee Mosaic

The Queen's Diamond Jubilee celebration this year was actually built on some code that I worked on during some down time at work to create a mosaic from a collection of small thumbnails. In the run-up to the Jubilee, Them was looking for a unique idea to celebrate. After some brainstorming, we thought to use my code and source the thumbnails from people who were tweeting about the Queen and the Jubilee. So, I spent a little time looking at the Twitter API to see how we could use it to gather the messages people were posting, and wrote a simple script which was run from a cron job every ½ hour pulling in all the tweets that mentioned either the Queen's Jubilee, or the Diamond Jubilee. This cron was eventually increased to once every 5 minutes to account for the increase in expected traffic and tweets.

To then pull in the images, I wrote another script that looped through the tweets we pulled in, and for each user we would read in the external image and save it locally. This worked well at first, until we noticed that more and more Twitter users were using one of the default egg profile pictures, and the script was altered to ignore those.

The third script run by cron was the one which built the image from the thumbnails. Initially, this built up the entire image in one go, but as the pool of thumbnails grew, so too did the image build time; just under 15 minutes at one point on an i7 with as much RAM as the code could use! I split the original image into smaller chunks and re-wrote the script to process each one of these separately. This brought the time right down to just over 3 minutes with each image being processed simultaneously. An instance of this script was called for each segment being processed, and once the final one had been completed, a quick call to ImageMagick had the segments resized and stitched back up to be used on the front-facing view for the visitors.

The front end for this was quite an interesting challenge, because it had to be able to do all of the following things:

All-in-all, there were over half a million tweets, sent by more than 300,000 people! One other slightly interesting fact of this was that the original base photo of the queen was one I'd taken myself at Madame Tussauds, London, as royalties for a photo of the lady herself would have proved too expensive for a small in-house project built mostly in my spare time!

Skills Used

The below are links back to the main portfolio list filtered by the selected skill.