I noticed last night that gifexplode.com is no longer a real site (some domain squatter took it, it looks like), so last night / this morning I recreated the service at gif-explode.com. It’s a simple concept, basically it takes in as input a URL to an animated gif and then spits out each frame of the animated gif. There’s a demo on the site if you want to see it but don’t feel like finding an animated gif.
On the tech side, I decided I wanted to try out Flask, which is a micro-webframework for Python. I’ve never used it but it’s pretty similar to a lot of other small web frameworks. From what I’ve garnered by using it and the examples, I don’t think it’s suited for medium to large websites, but for something as small as this it’s perfect. Using Python allowed me to use PIL for the image processing, and while PIL usually manages to piss me off, it did a decent job here.
For hosting I tried out Heroku. I used Heroku about 2 years ago for a Ruby on Rails project back when it was kind of a novel thing, but since then they’ve added support for a few other languages and have added a lot of new “add-on” features. Things went pretty smoothly, deployment-wise, though it didn’t like my id_rsa.pub file and I accidentally deployed to the wrong stack, but total time from signup to completion was probably less than an hour. Their docs are pretty good. I have mixed feelings though about Heroku in general, because it’s very expensive for things that can be free or cheap on an EC2 instance. I understand paying for convenience which is probably why Heroku is so popular, but I have a hard time imagining using it for anything bigger than a project like this, cost-wise.
One cool thing about this app is that it doesn’t actually save images anywhere. Each frame is base64 encoded and then embedded in an img tag. This makes the result page larger, but prevents the need for storage altogether and reduces HTTP requests substantially. As a side-effect it also prevents a malicious or ignorant user from using this service as an image host.
For the last step I think I’m going to make an “Animated GIF -> base64 encoded frames” API that other people can use, perhaps move my encoding code into it’s own module. We’ll see.