In the following code, I am trying to impose a transparent square on the image of some mountains. I thought this would work, but setting background_color = 'none' will not make the image transparent!
The result is a black square in the upper left corner - the desired result - the black square should be transparent.
require 'open-uri' require 'RMagick' image_url = 'http://farm9.staticflickr.com/8446/7937080514_62d7749860.jpg' bg = Magick::ImageList.new open(image_url, 'rb') do |f| bg.from_blob(f.read) end layer = Magick::Image.new(200, 200) { self.background_color = 'none' } bg.each do |frame| frame.composite!(layer, 0, 0, Magick::OverCompositeOp) frame.strip! end bg.write('out.jpg')
Here is my output image:

Edit: I'm on Mac, Lion, ruby 1.9.3p125, ImageMagick 6.7.5-7
Edit 2: This works great on Heroku! But not in my car. Heroku has the same version of ImageMagick. Strange: |
source share