Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Sinatra app to manipulate images given by url via mini_magick and image_magick. completly evented
branch: master
Failed to load latest commit information.
config add default route to test server is operational + add logrotate
log
public
spec move em stuff into config.ru so we can run specs
tmp
.gitignore no .bundle in git
Gemfile do image loading via http
Gemfile.lock do image loading via http
Rakefile add sinatra-synchrony
Readme.md pimp my readme
app.rb do image loading via http
config.ru do image loading via http
environment.rb with shotgun und rest-client

Readme.md

EventMachine-driven Sinatra app to manipulate images given by url via evented-magick (image-magick).

# resize
/magick?url=http://github.com/images/modules/header/logov3.png&size=200x100

# resize to 200 width / unlimited height
/magick?url=http://github.com/images/modules/header/logov3.png&size=200x

Startup

sudo gem install bundler
bundle install
thin start
curl localhost:3000/...see above...

As Middleware

TODO

Security

If the file config/secret (e.g. including 'my secret') exists, only requests with params hashed with this secret will be accepted.

require 'digest/md5'

def magick_query(params)
  hash = Digest::MD5.hexdigest('my secret' + params.map(&:to_s).sort.to_s)
  params = params.merge(:hash => hash)
  params.map{|k,v| "#{k}=#{v}"}.join('&')
end

`curl http://localhost/magick?#{magick_query(:url=>'xxx', :size=>'100x200')}`

Performance

Everything is evented, so its parallel and fast.
Add caching server infront of the app, e.g. Varnish or Rack::Cache to mak it production-ready.

TODO

  • add cropping

Author

Michael Grosser grosser.michael@gmail.com Hereby placed under public domain, do what you want, just do not hold me accountable...

Something went wrong with that request. Please try again.