convert -compose minus With custom color

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?".
Locked
MrGcGamer
Posts: 4
Joined: 2020-03-12T12:18:57-07:00
Authentication code: 1152

convert -compose minus With custom color

Post 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!

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert -compose minus With custom color

Post 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.
snibgo's IM pages: im.snibgo.com

MrGcGamer
Posts: 4
Joined: 2020-03-12T12:18:57-07:00
Authentication code: 1152

Re: convert -compose minus With custom color

Post by MrGcGamer »

Thanks I already did "-transparent Black"... what is clamping in this context?

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert -compose minus With custom color

Post 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.)
snibgo's IM pages: im.snibgo.com

MrGcGamer
Posts: 4
Joined: 2020-03-12T12:18:57-07:00
Authentication code: 1152

Re: convert -compose minus With custom color

Post 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?

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert -compose minus With custom color

Post 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.
snibgo's IM pages: im.snibgo.com

Locked