Extracting the layer transparency into an editable layer mask in Photoshop

28,389

Solution 1

This is what I do:

  1. Select the layer with transparency
  2. Click on Menu item Layer, Layer Mask, From Transparency.

The transparency will be converted into a layer mask, that you can manipulate from there.

EDIT: in Photoshop CS5 or later.

Solution 2

I have improved Mike's solution (Photoshop CS3):

  1. Open/create your image with 'baked in' transparency.
  2. Right click on the layer's icon in the Layers window and select Select Pixels.
  3. Layer menu -> Duplicate Layer
  4. Layer menu -> Merge Visible
  5. Repeat steps 3 and 4 several times until there are no semi-transparent pixels. The selection marquee should still remain.
  6. Layer menu -> Flatten image. You should see the transparency disappear. The selection marquee should still remain.
  7. Right click on the layer in the Layers window and select Layer from Background...
  8. Layer menu -> Layer mask -> Reveal Selection
  9. Done :-)

Solution 3

Easier way:

  1. Create a white color overlay on the image layer
  2. Create a black layer below the image

And now it should work!

Solution 4

** EDIT - Nevermind, I see now that this is no better than the first response. **

This can be done in Photoshop.

  1. Duplicate Image
  2. Menu>Image>Adjustments>Curves
  3. Grab the top right corner of the curve and drag it to the bottom right corner- Input 255 should read output 0. This is the inverse of your transparency mask. Click "OK"
  4. Menu>Image>Mode>Grayscale
  5. Flatten Image.
  6. Invert image. This is your mask.
  7. Select all
  8. Copy.
  9. Go back to your original image.
  10. Flatten image
  11. Unlock background
  12. Menu>Layer>Layer Mask>Reveal All
  13. Switch to the new channels palette and select the new mask channel.
  14. Click the "eye" to turn the mask view on.
  15. Paste
  16. click the eye to turn the mask view back off
  17. select the RGB channel again.

Done!

Note that if this is a common problem, it could easily be recorded as an action.

Share:
28,389
last-child
Author by

last-child

Updated on September 17, 2022

Comments

  • last-child
    last-child almost 2 years

    Is there any simple way to extract the "baked in" transparency in a layer and turn it into a layer mask in Photoshop? To take a simple example: Let's say that I paint a few strokes with a semi-transparent brush, or paste in a .png-file with an alpha channel. The rgb color values and the alpha value for each pixel are now all contained in the layer-image itself. I would like to be able to edit the alpha values as a layer mask, so that the layer image is solid and contains only the RGB values for each pixel.

    Is this possible, and in that case how? Thanks.

    EDIT: To clarify - I'm not really after the transparency values in themselves, but in the separation of rgb values and alpha values. That means that the layer must become a solid, opaque image with a mask.

  • last-child
    last-child over 13 years
    Thank you for the answer, but it's not quite what I'm after, as the rgb-values are not going to be the same as before... what I'm after is not the layer mask in it self, but the separation between rgb values and transparency so that they can easily be edited independently. The best way I know is to simply stack A LOT (>1000) of copies of the image on top of each other until even the nearly completely transparent pixels become opaque. Then paste in the transparency (extracted by your or some other method) as a layer mask.
  • Mike Fitzpatrick
    Mike Fitzpatrick over 13 years
    I can't find a better way in Photoshop than the layering method you describe. However, it is possible to save the image to a transparent PNG and then convert it to Netpbm PAM image using Png2pam, which can then be loaded back into Photoshop and you can easily convert the alpha channel to a layer mask. The two caveats are (1) Pngtopam is a command line utility for Linux or Windows/Cygwin and (2) pixels that are entirely transparent may not behave as you expect. If you want me to explain the process, please let me know.
  • DuckMaestro
    DuckMaestro about 12 years
    What version of Photoshop does this apply to? I'm on CS4 but don't see that option.
  • emc211
    emc211 over 11 years
    And it works almost the same way in The Gimp
  • macek
    macek about 11 years
    Worked for me in Photoshop CS6
  • TKoL
    TKoL almost 8 years
    @MichaëlWitrant upvoted because you called it "The Gimp"
  • Scott - Слава Україні
    Scott - Слава Україні about 6 years
    Can you explain how to do that? Please do not respond in comments; edit your answer to make it clearer and more complete.