I am trying to do something very simple using Sinatra and RMagick .
- Make the image through a simple file upload form.
- Use RMagick to resize.
- Then save it to the database for perseverance (inappropriate)
But after passing the RDocs and the endless head-test, I can’t get the shape image for the RMagick object cleanly .
This is a terrible thing that works for me now:
def image_resize(img_data)
filecount = rand
writer = File.new("/tmp/#{filecount}.jpg", "w")
writer.puts(img_data)
writer.close
resized_image = Magick::ImageList.new("/tmp/#{filecount}.jpg").first
resized_image.crop_resized!(100,100, Magick::NorthGravity)
resized.format = 'jpeg'
resized_image.to_blob
end
image_resize(params[:image][:tempfile].read)
So, how can I do the obvious right thing and just bind the form image data directly to the RMagick object without the need to write and read a disc.
Magick:: Image ImageLists, , .
-1,2.