Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.