Short presentation :
I'm using imagemagick since few years, but i think i'm still a beginner, i'm still discovering something, and i'm still in need of something new, and there are always so many ways to do it, that's just incredible !
And I adore too the command line ! It makes me think to my beloved computers : Oric, Amiga, old 386 with Ms-dos, the old time, the good souvenirs ...
Anyway, my question :
I like the operator -transparent, but i would like to make just the inverse, to change the transparency (1-255) into a defined color.
I've tried many things but i found nothing, i've tried with '-transparent-color' option and a GIF but without success.
I've tried also to manipulate the channel Alpha, with '-alpha' options, but i have'nt got no result.
I suppose there's a solution or certainly many, but I 've got not enough experience.
Does someone have an idea ?
Thanks for everything.
how to transform the transparency into a precise colour
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: how to transform the transparency into a precise colour
I don't understand what you want. Do you want all pixels that have a particular transparency (such as 23) to be changed to a particular opaque colour? Or do you want all pixels that have any transparency (ie alpha < 255) to be changed to a particular colour? Or something else?
Possibly useful documentation:
http://www.imagemagick.org/Usage/channels/#extract
http://www.imagemagick.org/Usage/basics/
http://www.imagemagick.org/Usage/color/
Possibly useful documentation:
http://www.imagemagick.org/Usage/channels/#extract
http://www.imagemagick.org/Usage/basics/
http://www.imagemagick.org/Usage/color/
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: how to transform the transparency into a precise colour
not sure which way you want it, so try
convert image -channel a -threshold 0 +channel -background red -flatten result
or
convert image -channel a -threshold 0 -negate +channel -background red -flatten result
or
convert image -channel a -negate -threshold 0 -negate +channel -background red -flatten result
or
convert image -channel a -negate -threshold 0 +channel -background red -flatten result
convert image -channel a -threshold 0 +channel -background red -flatten result
or
convert image -channel a -threshold 0 -negate +channel -background red -flatten result
or
convert image -channel a -negate -threshold 0 -negate +channel -background red -flatten result
or
convert image -channel a -negate -threshold 0 +channel -background red -flatten result
Re: how to transform the transparency into a precise colour
Sorry not to have been very clear, I've tried also the different possibilities and the first one seems to be the most successfull for what i want !
Now i have to understand it.
Thank you for everything, it will help me a lot !
Now i have to understand it.
Thank you for everything, it will help me a lot !
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: how to transform the transparency into a precise colour
This thresholds the alpha channel of the image only (-channel a -threshold 0) so that it is transparent. Then it turns back on the other channels (+channel). Then it flattens the transparent image over a red image so that the transparent parts become opaque red.convert image -channel a -threshold 0 +channel -background red -flatten result