GraphicsMagick replace all colors (except yellow) to transparent

884 Views Asked by At

Tried to replace all colors except yellow (with some -fuzz) to transparent without result. Didn't find anything in documentation maybe someone can help me.

Thank you.

As I know in ImageMagic there is +opaque, but I can't use this library

1

There are 1 best solutions below

0
On

This should do what you want. It makes the yellow pixels transparent and then inverts the alpha channel.

gm convert input.png +matte -matte -fuzz 5% -transparent yellow -operator matte negate 1 output.png

The "+matte" removes any existing transparency that might be in the input.png, then "-matte" adds an opaque alpha channel.

Tested with GraphicsMagick-1.3.20.