Hello, I have some images like these ones:
I would like to make the figures on the images (which are currently semi-transparent) be totally opaque, and go from the greyish color they are to being totally white (#ffffff). How would I go about this using convert? All of the images also have these different amounts of alpha on the figures, so I can't do a blind one-color-for-another replace.
Making semi-transparent white pixels in an image all a single color
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Making semi-transparent white pixels in an image all a single color
There are probably a few good ways to do this. My first thought was to threshold the alpha channel, and fill the positive with white. A command like this gets me pretty close to what you described...nihilazo wrote: ↑2018-10-18T09:03:44-07:00I would like to make the figures on the images (which are currently semi-transparent) be totally opaque, and go from the greyish color they are to being totally white (#ffffff). How would I go about this using convert? All of the images also have these different amounts of alpha on the figures, so I can't do a blind one-color-for-another replace.
Code: Select all
convert input.png -channel A -threshold 10% -channel RGB -fill white -colorize 100 output.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Making semi-transparent white pixels in an image all a single color
Your alpha channel is the same as your base image. You can see that from comparing the results of
convert test.png -alpha off aoff.png
convert test.png -alpha extract alpha.png
My thought was to make the base image pure white and then threshold the alpha channel.
Looking at GeeMack's solution, it appears to be similar but in the reverse order.
I thresholded the alpha channel more, so that the black lines in the image showed as transparency. If you do not want those outlines, then threshold at 0% (as user snibgo suggested below).
convert test.png -alpha off aoff.png
convert test.png -alpha extract alpha.png
My thought was to make the base image pure white and then threshold the alpha channel.
Code: Select all
convert test.png -channel rgb -evaluate set 100% +channel -channel a -threshold 50% +channel test1.png
Looking at GeeMack's solution, it appears to be similar but in the reverse order.
I thresholded the alpha channel more, so that the black lines in the image showed as transparency. If you do not want those outlines, then threshold at 0% (as user snibgo suggested below).
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Making semi-transparent white pixels in an image all a single color
As GeeMack says. To change "partially transparent" to "fully opaque", while leaving fully transparent unchanged, use "-threshold 0".
snibgo's IM pages: im.snibgo.com
Re: Making semi-transparent white pixels in an image all a single color
Thank you everyone! This works perfectly.