Skip to content

Instantly share code, notes, and snippets.

@ender672
Created March 23, 2012 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ender672/2175941 to your computer and use it in GitHub Desktop.
Save ender672/2175941 to your computer and use it in GitHub Desktop.
A really small image resizing rack application
require 'rack'
require 'oil'
app = lambda do |env|
r = Rack::Request.new(env)
io = File.new(File.join('images', File.basename(r.path)), 'rb')
body = Oil::JPEG.new(io, r[:w].to_i, r[:h].to_i)
[200, { 'Content-Type' => 'image/jpeg' }, body]
end
run app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment