samsonM
samsonM

Reputation: 19

How to colorize an image with multiply to add transparency to the colour with Image Magick

I would like to colorize an image with two colours, red on the left half and green on the right half but the colorize function just adds a coloured overlay to the image rather than multiplying it on. So I would like my image to look like this but it is currently looking like this. Here is the original image

My code at the moment is this:

convert normal.png \
            \( -clone 0 -crop 50x100% -fill red -colorize 60% \) \
            \( -clone 0 -crop 50x100%+64  -fill green -colorize 60% \) \
             -delete 0 -background none -flatten result.png

I have tried adding -compose multiply -composite to the code but I just get this which has the right effect but I cannot get it to the position that I want, heres the code for that:

convert normal.png \
            \( -clone 0 -crop 50x100% -fill red -colorize 70% \) \
            \( -clone 0 -crop 50x100%+64  -fill green -colorize 70% \) \
             -background none -compose multiply -composite result.png

Upvotes: 0

Views: 312

Answers (1)

GeeMack
GeeMack

Reputation: 5395

One simple approach would be to assemble the red-green overlay inside parentheses, then do a multiply composite over the input image.

magick lena_circ.png -size %wx%h \
   \( xc:red xc:green +append -scale 50x100% \) \
   -compose multiply -channel rgb -composite result.png

That command give me this result...

enter image description here

Upvotes: 1

Related Questions