Question

Given:

A texture texture and a photograph (with no transparent background) enter image description here

How do I give the photograph the texture?

To be specific, I want the following steps:

  1. Tile the texture. From here, I have: convert -size 1056x576 tile:Castillo_001.gif Castillo_tiled.gif
  2. Invert the result.
  3. Do a composite with the photograph equivalent to the "Color Dodge" blending mode in Photoshop.

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
Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top