leondewey.com

Image Hammer – fun with Sinatra and Mini magic

19 Oct 2010 – Sydney

Image hammer is basically a image manipulation service. It has two modes one is based on a profile you create via a rest api and the another revolves around a GET.

The GET

The get is the the most basic of the two approaches. You pass a image and some manipulation instructions along with a hash and get back the result.

http://image-hammer.heroku.com/anything.jpg?resize=100×100&url=http://leondewey.com/images/bike.jpg&hash=f48c45837044a00f622e66064cd631d5

The rest api

With this approach you create a profile (Via a http POST) then you get a clean url to hit

Then you can hit the following urls:
- http://image-hammer.heroku.com/leondewey-small/bike.jpg
- http://image-hammer.heroku.com/leondewey-medium/bike.jpg

Orignal
- http://leondewey.com/images/bike.jpg

Installation

$ git clone git://github.com/leondewey/image-hammer.git
$ cd image-hammer
$ ruby app.rb

Note you will need the following gems:
- sinatra
- sinatra/authorization
- sinatra/sequel
- mini_magick