Dimension
Fast, simplified image resizing for Ruby. No ImageMagick.
require 'dimension'
thumb = Dimension.open('tux.png')
thumb.generate('100x100') # => { :width => 100, :height => 100 }
thumb.save('resized.png')
Or generate and write file automatically.
thumb = Dimension.open('tux.png')
thumb.generate!('100x300!') # will write file as 'tux-100x300.png'
In memory processing
Yes sir, we have it.
thumb = Dimension.open(params[:file])
thumb.generate('200x300#')
thumb.image_data
You can also pass a block, which will ensure the original image is closed after processing.
get '/resize/:file' do
thumb = Dimension.open(params[:file])
thumb.generate('200x300@') do
thumb.to_response
end
end
Resizing geometries
This is taken directly from the excellent Dragonfly gem. The N/S/W/E gravities are not supported, though.
Author
Written by Tomás Pollak.
Copyright
(c) Fork, Ltd. MIT Licensed.