1
votes

I'm trying to use MiniMagick to resize 2 images and overlay one on top of the other. Heres the code I am using

require "mini_magick"

first_image  = MiniMagick::Image.new("spider.jpg")
first_image = first_image.resize("250x250")

second_image = MiniMagick::Image.new("q.png")
second_image = second_image.resize("250x250")

result = first_image.composite(second_image) do |c|
c.compose "Over"    # OverCompositeOp
  c.gravity "center"
  # c.resize("250x250")
end
result.write "output.jpg"

This overlays the images but neither is resized and the overlay image ends up awkwardly cropped. Ive tried making both the same size, making the bigger overlay image smaller and the smaller image bigger, but none seem to work. Any advice would be highly appreciated.