-compose Multiply not wroking with RGBA files

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
raabik
Posts: 9
Joined: 2019-04-11T12:28:31-07:00
Authentication code: 1152

-compose Multiply not wroking with RGBA files

Post by raabik »

I was trying to use:

magick composite "pattern.png" -compose Multiply "green.png" "mrp3.png"

what is wrong for RGB channels, only alpha channel has correct A amount, than I tested if it would work for only grayscale and for only one channel( R ) and it worked, as expected.

RGBA Images Mulitply(Not Wowking):
Image
Image
Result :
Image



magick composite "pattern_0.png" -compose Multiply "channels_0.png" "channelpattern.png"


Grayscale Images(Working)
Image
Image
Result
Image

I am frustraded how to get multiply to work independtly for each Channel.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -compose Multiply not wroking with RGBA files

Post by fmw42 »

What version of ImageMagick? What platform/OS?

magick composite is not as flexible as just magick for doing compositing. You should start using that.

Your pattern image has transparency. So you should be using -compose copy_opacity -composite with magick using its alpha channel and putting that alpha channel into the alpha channel of the green image.

Unix syntax:

Code: Select all

magick green.png \( pattern.png -alpha extract \) -alpha off -compose copy_opacity -composite result.png
Window syntax:

Code: Select all

magick green.png ( pattern.png -alpha extract ) -alpha off -compose copy_opacity -composite result.png
If you really want multiply, then

Code: Select all

magick green.png \( pattern.png -alpha extract \) -compose multiply -composite result.png
or

Code: Select all

magick green.png \( pattern.png -alpha off \) -compose multiply -composite result.png
Since the alpha channel is the same as the pattern image base channels.

But then the result will have a black background.
raabik
Posts: 9
Joined: 2019-04-11T12:28:31-07:00
Authentication code: 1152

Re: -compose Multiply not wroking with RGBA files

Post by raabik »

thanks for the answer, I somehow fixed that issue by using instead of the RGBA mask only an Grayscale mask, it than multiplies per channel as imo it should always.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: -compose Multiply not wroking with RGBA files

Post by GeeMack »

raabik wrote: 2019-04-11T13:10:04-07:00I was trying to use:

magick composite "pattern.png" -compose Multiply "green.png" "mrp3.png"

what is wrong for RGB channels, only alpha channel has correct A amount, than I tested if it would work for only grayscale and for only one channel( R ) and it worked, as expected.
I'm not sure exactly what result you're trying to achieve, but there are several ways to composite the alpha channel from one image onto another. Fred described a common method using "-alpha extract" and "-alpha off -compose copy_opacity" above. Here is a command that uses a different compose method to get pretty much the same result...

Code: Select all

magick green.png pattern.png -compose copyalpha -composite result.png
That essentially extracts the alpha channel from "pattern.png" and applies it to "green.png". The result seems clearer than your first example, and doesn't leave those tiny gray lines around the edges of the alpha.
Post Reply