How to read and image and get blob in ruby
I am using a homegrown captcha system. This uses Rmagick and Rmagick comes wit开发者_Go百科h ImageList. Existing code is like this.
im = ImageList.new("#{@@captcha_image_path}/#{captcha.pos}.JPG")
@imgdata = im.to_blob
send_data(@imgdata, :filename => 'captcha.jpg',
:type => 'image/jpeg',
:disposition => 'inline',
:nocache => Time.zone.now)
Above code works fine.
Now we are getting rid of Rmagick and we are using MiniMagick. We have generated some large number of images that will be displayed in random here. Now that I do not have access to ImageList, I was wondering how to get the blob data to be sent. Specifically how do I get @imgdata withoug using ImageList.
send_file '/path/to/image/file.jpg', :type=>"application/jpeg"
精彩评论