Given:
A texture and a photograph (with no transparent background)
How do I give the photograph the texture?
To be specific, I want the following steps:
convert -size 1056x576 tile:Castillo_001.gif Castillo_tiled.gif
Any clues for MiniMagick? Or any clue for the answer in ImageMagick?
Thanks a bunch.
Answer
ImageMagick:
convert IMG_1970.JPG \( -size 2816x1584 tile:background.png -negate \) -compose ColorDodge -composite out.jpg
Full answer:
# I just negatived the background already
img = MiniMagick::Image.open(File.join('IMG_1970.JPG'))
background = MiniMagick::Image.open(File.join('background_negative.png'))
background.combine_options do |c|
c.size "#{img['width']}x#{img['height']}"
c.tile background.path
end
img = img.composite(background) do |c|
c.compose "ColorDodge"
end
You are correct in creating the texture image with the tile:
format. Simply apply -negate option to invert the result. After which, a simple compose & composite command to apply the "Color Dodge" effect to any given image. See the Compose Examples article.
convert \( -size 1056x576 tile:Castillo_001.gif -negate \) \
source_image.jpg -compose Lighten -composite out_image.jpg