Page 1 of 1

convert -compose minus With custom color

Posted: 2020-03-12T12:45:29-07:00
by MrGcGamer
Hey, so I am using ImageMagick on mac (command line tool the newest version) and I was wondering if it possible to not use black as a replacement color when using:
convert file1 file2 -compose minus -composite result

If so please let me know. (I'd like to make it transparent)
(This is my first thread on here so do forgive if I did something wrong)

Thanks!

Re: convert -compose minus With custom color

Posted: 2020-03-12T13:00:31-07:00
by snibgo
I have removed your duplicate post.

I don't understand "not use black as a replacement color".

Your command replaces each pixel with the result of one pixel minus another pixel. Where the result is negative, values will be clamped to zero. If you don't want clamping, insert "-define compose:clamp=off" before the operation.

EDIT to add: And if you want to make black pixels transparent, insert "-transparent Black" after your operation.

Re: convert -compose minus With custom color

Posted: 2020-03-12T13:24:29-07:00
by MrGcGamer
Thanks I already did "-transparent Black"... what is clamping in this context?

Re: convert -compose minus With custom color

Posted: 2020-03-12T13:33:00-07:00
by snibgo
It means that any values that are less than zero are changed to be exactly zero. (Also, any values that are more than 100% of QuantumRange are set to exactly QuantumRange. But that can't happen if your inputs are in the range zero to QuantumRange.)

Re: convert -compose minus With custom color

Posted: 2020-03-12T13:36:11-07:00
by MrGcGamer
ok thanks... I really wanted to do is just take 2 images and remove every pixel which they have in common and leave the other alone... is this possible with ImageMagick?

Re: convert -compose minus With custom color

Posted: 2020-03-12T13:42:53-07:00
by snibgo
Then instead of "-compose Minus", you should use "-compose Difference". Then the black output pixels are where the inputs were equal, so "-transparent Black" will make those transparent.