I want to replace specific colours with some patterns using ImageMagick
.
I have a simplified example of what I would like to do.
Here I would like to replace the red
colour with the pattern pattern:right30
.
Here the image input is called test.png
.
So far, I got
magick test.png -fuzz 40% -tile pattern:right30 -opaque red room1.jpg
The issue is that my code gives me a black bar instead of the pattern.
The output I am looking for
You can do that in Imagemagick by creating a tiling image of your pattern and a mask image and compositing over the input.
Input:
convert bar_graph.png \
\( -clone 0 -tile pattern:right30 -draw "color 0,0 reset" \) \
\( -clone 0 -fuzz 40% -fill black +opaque red -fill white -opaque red \) \
-compose over -composite bar_graph_tiled.png