Are you tired of handling weird image resizing stuff in your application? Does generating images take a long time? Is it a pain to come up with different sizes of thumbnails? Do you wish you could reduce your image sizes by 20-50%? Would it be nice to have a single solution that handles all your imaging needs for all of your projects no matter what language / platform they are on?
ImageMonkey will handle this for you. In something like 20 lines of Ruby code.
If ImageMonkey is setup to listen at http://static.tanga.com, to fetch original images from http://www.tanga.com, and a request comes in to http://static.tanga.com/300×200!/images/logo.jpg, ImageMonkey will:
- Fetch http://www.tanga.com/images/logo.jpg (if it hasn’t already)
- Resize the image using ImageMagick to 300×200!
- Smush the image using http://www.smushit.com/ysmush.it. This will reduce filesizes significantly.
- Return the thumbnail to the client with appropriate http headers.
That’s pretty much it. This system allows you to easily make changes to your thumbnail sizes, squashing algorithms, etc without modifying application code.
You will want to use a http caching server (Varnish or Cloudfront (or both)) in front of this. Hosting on heroku w/ a Cloudfront custom origin is a fantastic idea.
Stuff left to do
- Change the URL to something like /resizer/200×300/rest/of/url.
- If a request comes in that doesn’t match /resizer, download/proxy the requested file (don’t try to thumbnail it)..
- Add a rails helper that you can use to easily integrate this into your Rails application.