I'm trying to post watermarked images to a url using rmagick and rest-client. When I generate the composite image, I save it (.write), read it back in with File.new, and then post that File object. Ideally though, I'd like to bypass the write operation because I'll never need this photo again. Is there any way to convert a Magick::Image object into a File object so that I can post it with rest-client?
require 'rmagick'
require 'rest-client'
photo = Magick::Image.read('myphoto.jpg').first
water_mark = Magick::Image.read('watermark.png').first
result = photo.composite(water_mark, 0, 0, Magick::OverCompositeOp)
result.write('result.jpg')
file = File.new('result.jpg', 'rb')
RestClient.post("http://example.com", :source => file)