36 Replies Latest reply: May 27, 2009 9:51 PM by Christian Davideck RSS

    Editing Alpha Channel

    G_Soucy Community Member

      Hi!

       

      I apologize if this posting has been answered before but I could not find a satisfying answer.

       

      I am looking for a mean to edit (not create and then edit) an already existing alpha channel in a PNG file (for example). Here is the scenario:

       

      • load a PNG file with a existing transparency layer created with some other application ( I see the usual checker board behind some transparent regions of the image)
      • select a region ( lasso, rectangle, ....)
      • change the transparency (alpha) of those pixels only, do not change anything else in the reste of the image (ex: make a region more transparent or more opaque). I do not want to edit the RGB content of the pixels, I want to edit their alpha value directly.
      • save back the file to a PNG file with modified alpha value.

       

      It sounds simple and obvious but I dont know how to do that. Would someone be kind enough to explain to me how to do it?

       

      Many thanks in advance!

       

      Gilbert

        • 1. Re: Editing Alpha Channel
          Gyno-jiz Community Member

          Control-click on the image layer in the layers panel, or bring up a selection of the layer transparency (or choose select > load selection > layer trans.). Then save that selection to a channel (select > save selection).

           

          Now you can restore the opacity of pixels that aren't fully transparent using filter foundry, alphaworks, or just duplicating the layer, merging down, duplicating again, merging down five or six times.

           

          Then load your saved selection and make it a layer mask by clicking the layer mask button in the layers panel (circle in rectangle).

           

          Now you can paint using a black or white brush to affect the transparency values of the layer. Save as PNG when you're done. See here for more in depth coverage:

           

          http://forums.adobe.com/message/1640851

          • 2. Re: Editing Alpha Channel
            Chris Cox Adobe Employee

            You can use layer masks or selections to increase transparency, but there is no good way to increase opacity (decrease transparency) or hand tweak values in the transparency channel.

             

            Also, be careful of terminology -- PNG supports a single transparency channel.  PNG does not support arbitrary alpha channels.

            You seem to assume that an alpha channel is always transparency, when that is not the case (alpha channels can contain anything, transparency is a small subset of possible alpha channels - and some file formats specify that they support only transparency).

            • 3. Re: Editing Alpha Channel
              Gyno-jiz Community Member

              Chris Cox wrote:

               

              You can use layer masks or selections to increase transparency, but there is no good way to increase opacity (decrease transparency) or hand tweak values in the transparency channel.

               

              Maybe that should be a feature request. 110% opacity.

              • 4. Re: Editing Alpha Channel
                Chris Cox Adobe Employee

                Actually, I'm just working on a feature to move the transparency channel to a place where it becomes editable.

                • 5. Re: Editing Alpha Channel
                  Semaphoric Community Member

                  Will it keep the original color value if set to zero? Or will it set the color to the background color of the layer, like it does now? I never understood the point of that.

                  • 6. Re: Editing Alpha Channel
                    Christian Davideck Community Member

                    J Maloney wrote:

                     

                    Chris Cox wrote:

                     

                    You can use layer masks or selections to increase transparency, but there is no good way to increase opacity (decrease transparency) or hand tweak values in the transparency channel.

                     

                    Maybe that should be a feature request.     

                     

                    support ++

                    • 7. Re: Editing Alpha Channel
                      Chris Cox Adobe Employee

                      "Will it keep the original color value if set to zero? Or will it set the color to the background color of the layer, like it does now? I never understood the point of that."

                       

                      Huh?  That makes zero sense.

                      • 8. Re: Editing Alpha Channel
                        Christian Davideck Community Member

                        Chris Cox wrote:

                         

                        "Will it keep the original color value if set to zero? Or will it set the color to the background color of the layer, like it does now? I never understood the point of that."

                         

                        Huh?  That makes zero sense.


                        I am in no position to judge whether or not Semaphoric's observations are true or false, but in case they are indeed true, it's really not that difficult to understand Chris:

                         

                        Semaphoric wrote:

                         

                        There is an important issue with a "Feature" of Photoshop's transparency: if, by any means, a pixel has been set to completely transparent (the value in its Alpha channel equal to zero), its original color value will be stripped out, and replaced with the current Background color, which will be seen when opacity is restored.
                        • 9. Re: Editing Alpha Channel
                          Chris Cox Adobe Employee

                          Again, that doesn't make sense.

                           

                          If you have zero opacity, the color channels have no meaning - no definition whatsoever (nothing there, no color values to speak of).

                           

                          And Photoshop doesn't replace colors under zero opacity until you do some operation that needs color values out in the undefined region (like some filters that spread edge colors outwards from visible regions).

                          • 10. Re: Editing Alpha Channel
                            Christian Davideck Community Member

                            Chris Cox wrote:

                             

                            Again, that doesn't make sense.

                             

                            If you have zero opacity, the color channels have no meaning - no definition whatsoever (nothing there, no color values to speak of).

                             

                             

                             

                            ....  yes, you are right, it doesn't make any sense. BUT ... only until such time as

                             

                            1) ... the user (by means of a plugin as PS doesn't support that natively very unfortunately) attempts to increase the opacity of a 0%-opacity-pixel ... hence our requests for an un-eraser-tool, that would do the reverse operation to the eraser tool (not decrease but increase a pixel's opacity) !

                            2) ... (see your own posting):

                             

                            Chris Cox wrote:

                             

                            ...  until you do some operation that needs color values out in the undefined region (like some filters that spread edge colors outwards from visible regions).
                            • 11. Re: Editing Alpha Channel
                              Christian Davideck Community Member

                              Chris Cox wrote:

                               

                              Actually, I'm just working on a feature to move the transparency channel to a place where it becomes editable.

                               

                              It's SOOOO wonderful to hear that, Chris!

                              I can imagine people jumping in the air, seeing this cool feature.

                              • 12. Re: Editing Alpha Channel
                                Zeno Bokor CommunityMVP

                                wouldn't it be easier to just use Layer Masks for "un-erasing"?

                                • 13. Re: Editing Alpha Channel
                                  Christian Davideck Community Member

                                  Christian Davideck wrote:

                                  hence our requests for an un-eraser-tool, that would do the reverse operation to the eraser tool (not decrease but increase a pixel's opacity) !

                                   

                                   

                                   

                                  ... which now becomes unnecessary with your transparency-channel -editing-feature.

                                  • 14. Re: Editing Alpha Channel
                                    Christian Davideck Community Member

                                    Zeno Bokor wrote:

                                     

                                    wouldn't it be easier to just use Layer Masks for "un-erasing"?

                                     

                                    Yes.

                                    If you had one in the first place.

                                     

                                    [Edit:] That's what J.Maloney meant in post #2 BTW.

                                    • 15. Re: Editing Alpha Channel
                                      Christian Davideck Community Member

                                      G_Soucy,

                                      you'll also find a lot of answers here: http://forums.adobe.com/message/1640834#1640834

                                      For example the solidify filter.

                                      • 16. Re: Editing Alpha Channel
                                        Reynolds (Mark) Community Member

                                        G_Soucy there is a workaround without plug ins - allowing you to increase your selected area to 100% Opacity. Just take your selected area and press command J multiple times. This will Stack duplicates of the area up in the layers panel. Then select all these duplicates and the original layer and press control E (merge) . Thats what Chris means when he says theres no good way at the moment, there isnt, but there are always work-throughs. An action could be made up which will effectively increase selected areas to 100%, without the use of plug-ins, in this way.

                                         

                                        When you've got opacity to 100% you can then use layer masking to control EXACTLY how opaque the area is. At the moment transparency in Photoshop should always be controlled with masking, an extremely powerful method - looks like this may change in the future though.

                                        • 17. Re: Editing Alpha Channel
                                          Semaphoric Community Member

                                          This is what I base my observation on:

                                           

                                          Running the Filter Factory, which can directly numerically manipulate the Transparency/Opacity channel, with a value of 1 in the 'A' (opacity) channel, and then running it with a value of 255 will yield the original image.

                                           

                                          Running it with a value of zero, and then 255 yields the background color of the layer.

                                           

                                          OK, with zero opacity the color value has no meaning. So why go the extra (meaningless) step of changing the values in the color channels? If those were left unchanged, we could then 'Un-erase'.

                                          • 18. Re: Editing Alpha Channel
                                            Christian Davideck Community Member

                                            Semaphoric, did you write this FilterFactory plugin yourself ? Do you think you could you post it here in that case, or otherwise a web link ?

                                            • 19. Re: Editing Alpha Channel
                                              Christian Davideck Community Member

                                              Semaphoric wrote:

                                               

                                              Running it with a value of zero, and then 255 yields the background color of the layer.

                                               

                                              BTW, what do you mean with "background color of the layer" ? You're sure layers have a BG color? I thought there was only a currently selected foreground color and background color (which wouldn't be saved into your .psd document).

                                              • 20. Re: Editing Alpha Channel
                                                Semaphoric Community Member

                                                The Filter Factory was an Adobe product that shipped with Photoshop until recently (at least until CS2, maybe CS3). It was never installed by default; it was an optional plugin found in the Goodies folder of the distribution disc.

                                                 

                                                You can find lots of filters created with it on the Web, but I don't know where you'd get th FF itself these days.

                                                 

                                                You are right about the background color. I was thinking of the Layer color, which is to make them distinctive in the Layers palette. So, just make that "yields the background color".

                                                • 21. Re: Editing Alpha Channel
                                                  Christian Davideck Community Member

                                                  Actually I wasn't asking where to get FilterFactory from, but rather what's the name of the (FF-made) filter you are using and where could we get it from? Thanks.

                                                  • 22. Re: Editing Alpha Channel
                                                    Christian Davideck Community Member

                                                    Semaphoric wrote:

                                                     

                                                    This is what I base my observation on:

                                                     

                                                    Running the Filter Factory, which can directly numerically manipulate the Transparency/Opacity channel, with a value of 1 in the 'A' (opacity) channel, and then running it with a value of 255 will yield the original image.

                                                     

                                                    Running it with a value of zero, and then 255 yields the background color of the layer.

                                                     

                                                    OK, with zero opacity the color value has no meaning. So why go the extra (meaningless) step of changing the values in the color channels? If those were left unchanged, we could then 'Un-erase'.

                                                     

                                                    If you didn't write the filter yourself, than (I guess) you can't know if the color value of a 0%-opacity-pixel is REALLY gone, or if its just the way the plugin works (i.e.set 0% opacity pixels to 100% opacity and fill with currently selected BG color). It might have nothing to do with Photoshop itself.

                                                    • 23. Re: Editing Alpha Channel
                                                      Semaphoric Community Member

                                                      OK, I just ran a test.

                                                       

                                                      Open new doc. Add a new layer, and fill it with some color. Hide the Background layer.

                                                       

                                                      Mousing over the image shows the color in the Info panel. Use the FF to reduce the opacity to a value of 1, and the Info panel still shows the full value of the color. Use th FF to set the opacity to zero, and the Info panel shows nothing at all (blank) for the color value.

                                                       

                                                      So I gather that what Chris was saying is that if the Opacity is zero, the color information is stripped out. Looking at it this way I can certainly see the point of it, as it would decrease the memory/storage space needed for the blank plixels - only one channel rather than four.

                                                      • 24. Re: Editing Alpha Channel
                                                        G_Soucy Community Member

                                                        Thank you all for the answers. As you can guess, I am not an expert with Photshop. However, I am 100% sure that Photoshop will erase colors in full transparency regions. I wrote a format plugin to support our own image format and that`s the first thing that I noticed (colors are gone when I tried to save them back) and I know that they were there to start with. This is a problem for us because we could decide (and we will often) to increase pixel opacity but it is not very good if the colors behind have been deleted. What the point of editing transparency if the colors behind have been changed? That would be the first thing to fix (since I consider that as a bug personnally).

                                                         

                                                        As a beginner user of photoshop, I would have expected a simple transparency editor tool as mentionned in the discussion. Maybe my needs are different for the average user but I think that this would be a must for such a software. Later today I will experiment with the suggestions provided to increase pixel transparency but, at first glance, it does not sound simple.

                                                        • 25. Re: Editing Alpha Channel
                                                          Christian Davideck Community Member

                                                          Semaphoric wrote:

                                                           

                                                          So why go the extra (meaningless) step of changing the values in the color channels? If those were left unchanged, we could then 'Un-erase'.

                                                           

                                                          G_Soucy wrote:

                                                           

                                                          This is a problem for us because we could decide (and we will often) to increase pixel opacity but it is not very good if the colors behind have been deleted. What the point of editing transparency if the colors behind have been changed? That would be the first thing to fix (since I consider that as a bug personnally).

                                                           

                                                          As a beginner user of photoshop, I would have expected a simple transparency editor tool as mentionned in the discussion. Maybe my needs are different for the average user but I think that this would be a must for such a software.

                                                           

                                                          I fully support these suggestions.

                                                          See also:

                                                          http://forums.adobe.com/message/1640834#1640834

                                                          • 26. Re: Editing Alpha Channel
                                                            Semaphoric Community Member

                                                            Maybe you should re-write your format plugin to open the image with full opacity and a layer mask. Then, you could edit the mask all you like, and the color information would stay constant.

                                                            • 27. Re: Editing Alpha Channel
                                                              Christian Davideck Community Member

                                                              Good idea. But there is still the issue that the plugin wouldn't know how to handle 0%-opacity-pixels, *in case* PS has REALLY stripped their color values.

                                                               

                                                              And I still couldn't find the specific (FilterFactory made) filter you were talking about, in case you could tell me:

                                                               

                                                              Christian Davideck wrote:

                                                               

                                                              Actually I wasn't asking where to get FilterFactory from, but rather what's the name of the (FF-made) filter you are using and where could we get it from? Thanks.

                                                              • 28. Re: Editing Alpha Channel
                                                                G_Soucy Community Member

                                                                Semaphoric wrote:

                                                                 

                                                                Maybe you should re-write your format plugin to open the image with full opacity and a layer mask. Then, you could edit the mask all you like, and the color information would stay constant.

                                                                 

                                                                Thank for the comment. I got the plugin to support both full opacity and regular transparent modes using a popup message for now to switch (transparent is the one for which I posted that message originally).

                                                                 

                                                                I found that in full opacity mode (loading the alpha channel as the 4th channel), I can do pretty much all the editing that I want. That works well with CS2 but not yet with CS4 (the CS4 SDK demo "simpleFormat"does not work either with CS4 so  I posted a message in the SDK forum  -  the problem is that the 4th channel is not loaded in CS4 and also the image is loaded as a "Smart Object"). If you know anything about that issue, any help; is more then welcome...

                                                                 

                                                                Thanks!

                                                                • 29. Re: Editing Alpha Channel
                                                                  harry teasley Community Member

                                                                  I have asked many times, through many versions, for tools to manipulate opacity directly, instead of simply RGB. The painting tools and selection tools, specifically, would be greatly enhanced with opacity settings.

                                                                   

                                                                  If I could use the magic wand to select all pixels of 4% opacity or less within a layer, it would be amazing. If I could use a paintbrush to paint 100% opacity into any pixel that has any data in it at all, that would be great.

                                                                   

                                                                  The key to the request, to make it make sense to users, is that the opacity painting tools would have to ignore empty pixels, while the opacity selection tools would not: any pixel without data in it at all would not be painted into when painting opacity, but would be selected for the purposes of, say, selecting the least opaque pixels in a layer.

                                                                   

                                                                  I have amazingly strong feelings about this: I do images where the bounding box of the data in a layer is important, and a stray pixel can mess things up. Or I've wanted to put a layer effect on a layer, but the plethora of nigh-invisible pixels with data in them cause the effect to be unusable. I have wanted to manipulate opacity directly long before now, without having to do an interim alpha-channel mockup. I've made this request for several versions now, and really hope to see something happen. My history-destroying "Opaquify" action could go away (the one that stamps dupes of a layer onto itself sixteen times). It would rock.

                                                                  • 30. Re: Editing Alpha Channel
                                                                    Semaphoric Community Member

                                                                    To select all pixels with a less than 'n' opacity:

                                                                     

                                                                    Select > Load Selection, using 'Layer x Transparency'.

                                                                     

                                                                    Enter Quick Mask mode. Image > Adjustments > Threshold, with a value of n.

                                                                     

                                                                    Invert, and exit Qick Mask.

                                                                     

                                                                     

                                                                     

                                                                    To make all pixels that are not fully transparent become fuly opaque, paste the following into the A field of the Filter Factory and run it:

                                                                     

                                                                    a == 0 ? 0 : 255

                                                                     

                                                                     

                                                                    You can fake painting opacity by entering Quick Mask mode, painting the area you wish to opacify, exiting Quick Mask, and running the above filter.

                                                                    • 31. Re: Editing Alpha Channel
                                                                      harry teasley Community Member

                                                                      Semaphoric wrote:

                                                                       

                                                                      To select all pixels with a less than 'n' opacity: <...>

                                                                      I hope I didn't sound like I don't know the workarounds. It's just that they're terrible. Everything involves not dealing directly with the layer, but dealing with a mask/alpha representation of that layer. The extent to which I want to edit opacity is such that I want much more direct access: I want the magic wand to work on the actual layer, selecting opacity. If I don't like the selection, I want to ctrl-z, adjust the tolerance, and reselect, very quickly. I want an Edit > Fill > Contents Use Opacity option, to flood fill pixels containing data with opacity. I don't want to deal with intermediary representations, that's too removed, with too many steps. I do that now, when I have to: I don't want to.

                                                                      • 32. Re: Editing Alpha Channel
                                                                        Christian Davideck Community Member

                                                                        harry teasley wrote:

                                                                         

                                                                        I have asked many times, through many versions, for tools to manipulate opacity directly, instead of simply RGB. The painting tools and selection tools, specifically, would be greatly enhanced with opacity settings.

                                                                         

                                                                        If I could use the magic wand to select all pixels of 4% opacity or less within a layer, it would be amazing. If I could use a paintbrush to paint 100% opacity into any pixel that has any data in it at all, that would be great.

                                                                         

                                                                        [...]  I've made this request for several versions now, and really hope to see something happen.

                                                                         

                                                                        support ++

                                                                         

                                                                        • 33. Re: Editing Alpha Channel
                                                                          Christian Davideck Community Member

                                                                          a == 0 ? 0 : 255

                                                                           

                                                                          that's cool. thanks a lot for sharing.

                                                                          • 34. Re: Editing Alpha Channel
                                                                            Christian Davideck Community Member

                                                                            G_Soucy wrote:

                                                                             

                                                                            As a beginner user of photoshop, I would have expected a simple transparency editor tool as mentionned in the discussion. Maybe my needs are different for the average user but I think that this would be a must for such a software.

                                                                             

                                                                            I agree.

                                                                             

                                                                            Semaphoric wrote:

                                                                             

                                                                            if the Opacity is zero, the color information is stripped out. Looking at it this way I can certainly see the point of it, as it would decrease the memory/storage space needed for the blank plixels - only one channel rather than four.

                                                                             

                                                                            Yes, buton the other hand, you've lost the color information forever and can't get it back with a (future) opacity tool or transparency channel editing (for example via FilterFactory).

                                                                            • 35. Re: Editing Alpha Channel
                                                                              harry teasley Community Member

                                                                              Christian Davideck wrote:

                                                                              Yes, buton the other hand, you've lost the color information forever and can't get it back with a (future) opacity tool or transparency channel editing (for example via FilterFactory).

                                                                               

                                                                              You wouldn't want it back: with no way to know what was formerly there, it would result in unexpected behavior.

                                                                              • 36. Re: Editing Alpha Channel
                                                                                Christian Davideck Community Member

                                                                                You wouldn't want it back: with no way to know what was formerly there, it would result in unexpected behavior.

                                                                                 

                                                                                I don't think so, but in case you aren't pleased with the results, you can always go back 1 step in history.