Hacker News new | ask | show | jobs
by andrewingram 5798 days ago
At work I developed a wsgi script that use Python Imaging Library to resize images on demand. You can see it in action here:

http://dyn4.media.forbiddenplanet.com/products/2148557.jpg.s... http://dyn4.media.forbiddenplanet.com/products/2148557.jpg.s...

Basically, if you chop off the dyn4 sub-subdomain and everything after .jpg you can see the original unmodified image. You can also change the extension at the end to change the format of the image (jpg,png or gif). We cache the files to /tmp which we periodically clear out. Whilst it might be more efficient of going down the route of pre-generating all the images we'll need, it's very convenient being able to do it on the fly and to be honest for a site of our size (225,000 visits/month) it's barely a spec on the CPU load of our media server.

There's also an apache module that uses ImageMagick to do something similar:

http://github.com/beetlebugorg/mod_dims

I have to be honest though, I prefer the API for my version and it gives the files a meaningful name in the /tmp folder as well as the user's internet history.

Unfortunately my version isn't open source (yet?) and the code is a bit of a mess, but it's something we have considered opening up.