6

I am basically trying to write this command with mini_magick.

gm composite -compose Copy -geometry +0+210 note-transparent1.png note-rugby.png note-rugby-e.png

This is my code:

 image = MiniMagick::Image.open("note-transparent1.png")

result = image.composite(MiniMagick::Image.open("note-rugby.png") do |c|
  c.compose = "Copy"
  c.geometry = "+0+210"
end)
result.write "note-rugby-e.png"

The images are composited and written to the new file; however the geometry isn't respected. The image is not offset.

I also tried setting the mini_magick processor to ImageMagick instead of GraphicsMagick, but I get the same result.

Any ideas?

rmw
  • 1,253
  • 1
  • 12
  • 20

2 Answers2

5

I am using mini_magick with ImageMagick, and the below code works for compositing.

bground = MiniMagick::Image.open("bground.jpg")
image = MiniMagick::Image.open("image.jpg")

result = bground.composite(image) do |c|
  c.gravity "NorthWest"
  c.geometry '400x400+20+56' 
end

result.write "output.jpg"
Rhb123
  • 118
  • 1
  • 8
2

According to rubydoc minimagic

first_image = MiniMagick::Image.open "first.jpg"
second_image = MiniMagick::Image.open "second.jpg"

result = first_image.composite(second_image) do |c|
 c.compose "Over" # OverCompositeOp
 c.geometry "+20+20" # copy second_image onto first_image from (20, 20)
end
result.write "output.jpg"
Arvind singh
  • 1,312
  • 15
  • 15