Page 1 of 1

How to remove semitransparent pixels

Posted: 2015-06-03T15:46:13-07:00
by Wolfgange
I would like to remove pixels with less than ~20 opacity, and "Anti-erase" anything else. (I'm not quite sure of the technical name for it, but what I mean by "Anti-erase" is to make the pixel the same color with no transparency).

I've already tried this:

Code: Select all

convert -alpha off input.png miff:- | convert -transparent white - miff:- | convert -transparent black - output.png
But the problem is, I'm left with random pixels that were really transparent, now completely shown, and the pure white and black of the image is now transparent. Is there a way I can achieve the results I want? Here is a sample image input and output:
Image

Re: How to remove semitransparent pixels

Posted: 2015-06-03T16:06:19-07:00
by Wolfgange
I've solved my problem. By converting to gif and back, the semitransparent pixels are automatically either removed or "Anti-erased". Thus, this works perfectly:

Code: Select all

convert input.png gif:- | convert - output.png

Re: How to remove semitransparent pixels

Posted: 2015-06-03T16:09:05-07:00
by fmw42
It would have been nice if you had provided the source image by itself. So, I cropped it out and called it Example2.png. The following seems to work for me.

Code: Select all

convert Example2.png -channel alpha -threshold 20% +channel NewExample2.png
In the future, please always provide your version of Imagemagick and your platform. Syntax may be different on Windows than Unix systems.