require "rmagick"
include Magick
# Load Recipe Image From File
recipie_image = Image.read("../recipie.jpg").first
# Load the Chef Image
chef_image = Image.read("../chef.png").first
# Get size of the recipe image
width, height = recipie_image.columns, recipie_image.rows
# Generate the Gradient Image Based On An ImageMagick "canvas creation string"
gradient_image = Image.read("gradient:rgba(0,0,0,0.7)-rgba(0,0,0,0.0)") do
self.size = "#{width}x#{height}"
end
# Now, to overlay the gradient_image on top of the recipie_image
recipie_image = recipie_image.composite( gradient_image.first, 0, 0, OverCompositeOp)
# Scale down the chef image so that it looks good
chef_image = chef_image.scale(0.5)
# Finally, to overlay the chef image on top of that
recipie_image = recipie_image.composite( chef_image, 30, 30, OverCompositeOp)
#Write the final image to the file:
recipie_image.write(\'output.jpg\')