Hi
I have an image with say 3 known colours and I want to go through the 3 colours, replace them with another colour and apply an overlay to the colour changed areas. It is being handled by a PHP script, so I can use that to loop if that's easier.
To clarify:
1) replace colour X with colour Y
2) apply texture overlay (multiply/screen) to new colour Y area
3) repeat 1 and 2 as required
4) output combined image
I have tried a lot of different combinations of commands I found here - but I either end up applying the overlay to the entire image or some other incorrect
I'm using ImageMagick 6.7.8-9
Any help would be appreciated.
Apply overlay image to masked areas
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Apply overlay image to masked areas
You will have to mask to overlay so that it does not change the other two colors. Perhaps you should post a link to your input image and specify what your platform is.
Re: Apply overlay image to masked areas
I'm using command line through PHP
Attached is an image with 3 colours and an example of a texture to be applied to (there are a few) - one would be applied to each area


Attached is an image with 3 colours and an example of a texture to be applied to (there are a few) - one would be applied to each area


- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Apply overlay image to masked areas
In Unix syntax:

For Windows, remove \ from before \( and before \) and replace end of line \ with ^.
Code: Select all
convert texture.png -rotate 90 texture2.png
Code: Select all
convert image.png +write mpr:img +delete \
\( mpr:img -fill pink -opaque "rgb(0,191,242)" \) \
\( -clone 0 -fill white -opaque pink -fill black +opaque white \) \
texture.png +swap \
-compose multiply -composite +write mpr:img +delete \
\( mpr:img -fill skyblue -opaque "rgb(243,109,79)" \) \
\( -clone 0 -fill white -opaque skyblue -fill black +opaque white \) \
texture2.png +swap \
-compose multiply -composite result.png

For Windows, remove \ from before \( and before \) and replace end of line \ with ^.
Re: Apply overlay image to masked areas
You are an absolute champion - a few of my attempts were close but not quite right. Thanks a lot.