6

Assume I have an icon on a pure white background in a PNG image. The icon is a solid color, with edges anti-aliased, so they are blended with white. I need to delete the white background so that the non-content is transparent. How can I get the anti-aliased edges to blend from the fill color to transparent, instead of white?

There is a similar question on the site, but this is actually a different case: dealing with solid colors, and anti-aliasing of just the edges, not reblending entire portions of the image. I don't think the answer from the other question applies. I can't reasonably apply a gradient to just the one-pixel edge of an icon. There aren't enough pixels. Also, this method doesn't scale well when the icon edges are irregular (like a Twitter bird).

Perhaps the question is whether it's possible to de-antialias an icon, knowing the foreground and background colors exactly, and to re-antialias it on a transparent background.

7
  • Have you explored Layer > Matting > Remove White/Black Matte within Photoshop? There's also a possibility the Blend If options in Photoshop may help. However, you've not specified any software and it's difficult to envision what you need exactly without a sample image (which is probably why the similar question came into play before).
    – Scott
    Mar 12, 2014 at 19:47
  • 1
    I disagree with the assessment here: the question and answer are very nearly the same. I suspect the OP is being misdirected by the idea of the reflective area below the icons which requires special handling, but I ask the question: how is that materially different than the anti-aliasing at the edges? What purpose did the gradient serve? The key is the mask applied to the layer and how you isolate/manipulate the transparency values at the proper pixel locations
    – horatio
    Mar 12, 2014 at 20:17
  • @horatio I disagree with your disagreement. This is a separate question as the techniques to answer it (as I've answered) can be applied here, but not necessarily for the other question. Further, the other question is a year old and has no valid answer (note, the top voted answer didn't even look like they read the question and the others don't provide a real solution).
    – rgthree
    Mar 12, 2014 at 20:58
  • The accepted answer contains a clear solution. Your answer uses the exact same technique but differs only in the manner in which you created the mask. You know this because you say it, but your answer is also predicated on (what they call in physics) a "spherical cow": the simple case which ignores real-world difficulties in order to make the math easier. (The weakness is that it relies on no grey in areas he may not want masked). That is not to say your answer isn't helpful, but it certainly is a duplicate.
    – horatio
    Mar 12, 2014 at 21:31
  • 1
    @horatio I apologize, I didn't see there was an accepted answer (I was filtered on "votes"). Regardless, my answer would provide better results even in the linked answer by avoiding the harsh stops on the gradients, so this is not a "spherical cow" by any means. If this was simply marked as a "duplicate" by a year-old answer you would be robbing those who stumble upon this of an arguably better technique? Additionally, in design there are a lot of ways to accomplish something and I don't necessarily think we should be so quick on the trigger to mark something today a duplicate of yesteryear.
    – rgthree
    Mar 12, 2014 at 22:22

1 Answer 1

8

I usually create a new alpha channel based on the selection of the color.

  1. Assuming you are starting with one flattened layer with a color on top of a white matte background. This works best if your color is dark/black. Play with some adjustments to get it as dark as possible.

    matte image

  2. Open your Channels palette and ctrl+click on the RGB channel to load it's selection, then ctrl+shift+i to inverse the selection.

  3. Press the "Create a New Channel" while your selection is still active. This will create an alpha channel for you and focus on that.

    enter image description here

  4. Go back to your Layers palette and the alpha selection should be active. Create a new layer and select the Fill tool of the color of your choice and fill in your new, matte-free single-color icon.

    enter image description here

1
  • 1
    Looks great, cool technique! Accepting! I think the tricky part may be figuring out a general solution to get the arbitrary solid color to scale to black, with any blending scaling to shades of gray, but I don't think that should be insurmountable.
    – acjay
    Mar 12, 2014 at 21:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.