0

Here is my code:

process :watermark   

def watermark
   second_image = MiniMagick::Image.open("https://s3.amazonaws.com/....logo.png")
   manipulate! do |img|
   result = img.composite(second_image) do |c|
     c.compose "Over"    # OverCompositeOp
     c.gravity "Southeast" 
   end
    result
   end
 end

The problem is that the second image shows up as a square or a rectangle and does not show up with a transparent background.

How do I get my logo to composite on top of the images with a transparent background?

EDIT

I tried the following code

def watermark
  def second_image
    second_image = MiniMagick::Image.open("https://s3.amazonaws.com/...logo.png") do { "white" => transparent }
    second_image.save
  end  
  manipulate! do |img|
  result = img.composite(second_image) do |c|
     c.compose "Over"    # OverCompositeOp
     c.gravity "Southeast" # copy second_image onto first_image from (20, 20)
  end
  result
  end
 end
end

which didnt work and resulted in second_image not being composited on the upload and returned only the upload.

Edit 2

My image was not actually transparent, :/

Shaomai888
  • 116
  • 1
  • 8

1 Answers1

0

Have a look at this forum for your answer. http://www.imagemagick.org/discourse-server/viewtopic.php?t=20262

mcphersonjr
  • 733
  • 12
  • 35
  • 1
    Is this the line I should be looking at? "convert b.png -transparent "#FFFFFF" -matte c.png" the background to my logo is white. i don't know how to write this into the code though. – Shaomai888 Jan 07 '16 at 02:59