Search code examples
webpngtransparencyfrontendphotoshop

Why is a PNG file often larger without transparency?


Often when I am saving a PNG-24 file with transparent areas for web in Photoshop, the file size gets larger when I deselect the transparency option.

enter image description here

On the file I was just working on, the file size with transparency was 45.28k, but without transparency it was 53.71k, which is not an insignificant difference.

Can anyone explain this behaviour?


Solution

  • Simplified answer: PNGs save purely transparent pixels as a binary value, whereas they save values with color using the equivalent of an RGB or RGBA value (which takes much more space than one bit).

    In actuality, pixels that are not purely transparent are grouped in chunks, which are analyzed for their color requirements and use the minimum applicable option for color depth in order to save space pre-compression. Before that happens, though, pixels are first examined to see if they are purely transparent in order to ensure both that they're represented accordingly and that other pixels do not become transparent in error. You can read more here.