6 Replies Latest reply on Aug 17, 2016 10:47 AM by fnordware

    How to open 32 bit PNG with unpremultiplied alpha?

    egearbox Level 1

      I've got the latest Photoshop CC (2014) and I've been trying to figure out how to import a 32 bit PNG file with an embedded but unpremultiplied alpha channel in it.  So this is a PNG image with four channels:  Red, Green, Blue, and Alpha.  Unfortunately, when I open it in PS, I get a three channel (R, G, B) image where PS has cheerfully premultiplied the alpha into the other channels, as you can see here:





      The "glow" is the Alpha channel's unwanted effect.


      I know the Alpha channel is still there because if choose Channel-->Split, I get four grayscale images:  myimage_red, myimage_green, myimage_blue, and myimage_transparency.    So the Alpha information is being kept separate, but PS is being "helpful" and premultiplying it on the open.


      Is there a setting or anything else that can overcome this behavior?


      Note:  The reason for this is that I'm using the "alpha" channel for something else (ambient occlusion) in a CG program and it should not be being used for transparency at this point.   (Long story.)

        • 1. Re: How to open 32 bit PNG with unpremultiplied alpha?
          Level 7

          No, Photoshop is not premultiplying at all.

          Photoshop is showing you the image you opened, with the transparency information in the image.


          Photoshop does not use premultiplied transparency, and neither does the PNG file format.

          So either the program that created the PNG wrote it incorrectly, or you are very confused about transparency and premultiplication.


          Alpha channels are not the same as transparency. Alpha channels are a super set of all possible extra channels, and transparency is a very specific subset of alpha channels closely related to the color data in the image.

          If your CG program is writing something other than transparency in PNG, then your CG programmers failed to read the documentation for the PNG format (which very clearly spells out what the fourth channel in PNG must represent).


          If you wish to separate the transparency from the color image data, use the command Layer -> Layer Mask -> From Transparency.  That will move the transparency into a layer mask where you can disable it, copy it separately, etc.

          • 2. Re: How to open 32 bit PNG with unpremultiplied alpha?
            egearbox Level 1

            Thank you for your prompt response!   I apologize if I misused the term "premultiplied."   Here's what I am familiar with the term from:   https://helpx.adobe.com/premiere-pro/using/compositing-alpha-channels-adjusting-clip.html


            With straight (or unmatted) channels, transparency information is stored only in the alpha channel, not in any of the visible color channels. With straight channels, the effects of transparency aren’t visible until the image is displayed in an application that supports straight channels.

            With premultiplied (or matted) channels, transparency information is stored in the alpha channel and also in the visible RGB channels, which are multiplied with a background color. The colors of semitransparent areas, such as feathered edges, are shifted toward the background color in proportion to their degree of transparency.


            So, here is what I see on my Photoshop screen when I open this image.  Note that there are only THREE channels displayed, Red, Green and Blue (and the composite RGB channel).  All three of them display transparency, allowing the (in this case checkered) background to show through:



            Now, if I select Channels-->Split Channels I get these FOUR images.   Note that there is a "Transparency" channel which has my separate information that I want, and there are three color channels, none of which display transparency.   This is what I meant by "premultiplied".   In the default mode above, Photoshop has "multiplied" each color channel by the "Transparency" channel.   This is the behavior I was seeking to avoid.    Can you offer any further advice on how to prevent this automatic use of the "Transparency" layers, or is this something that Photoshop does not support at this time?



            rad3_rgb_025_blue.png  "Blue"

            rad3_rgb_025_green.png  "Green"


            rad3_rgb_025_red.png  "Red"

            • 3. Re: How to open 32 bit PNG with unpremultiplied alpha?
              Level 7

              Yes, you are badly misusing the word "premultiplied".

              There is no premultiplication going on here -- just that you have something in the transparency channel that is not transparency, and thus does not look correct when applied as transparency like PNG says it must be.

              Read my previous post for how to extract the transparency channel.


              Also, you need to talk to your CG program authors about fixing their PNG export to actually comply with the PNG specification.

              • 4. Re: How to open 32 bit PNG with unpremultiplied alpha?
                egearbox Level 1

                Thanks for the help.   I'll stop calling it "premultiplied."

                • 5. Re: How to open 32 bit PNG with unpremultiplied alpha?

                  Technically users should be rendering to a floating point format such as OpenEXR 16-half for later compositing. Renderers will put arbitrary data into an Alpha if specified by the user (in this case occlusion in alpha). Which has nothing to do with the PNG specification and everything to do with the limitations imposed by Adobe products.


                  However I suspect many users don't use EXR because Photoshop (and pretty much all of Adobe's Creative Suite) has no idea what to do with an EXR (and layers) in any meaningful manner other than convert the gamma and then throw everything away when you're forced to convert it to 16-bit (not 16-half) to manipulate. This makes using a correct pipeline with CG output nearly impossible in Photoshop or After Affects without severe hackery.


                  My suggestion: Someone should talk to Adobe about supporting the full OpenEXR specification. The layer menu would be perfectly fine to handle this.


                  Given the ubiquity of 3D content I'm frustrated Adobe hasn't seen need to improve this for a really long time now and sees fit to slap the hand of users asking for help and laying the blame on the CG software.

                  • 6. Re: How to open 32 bit PNG with unpremultiplied alpha?
                    fnordware Level 3

                    If you install SuperPNG you can load the file while holding down Shift and re-direct the Alpha to the Channels palette.