4

Can I know whether a PNG file was compressed and how (at least, whether it was a lossless compression) in Windows? When I open the standard file properties dialog from the Windows Explorer, I see no properties regarding this.

Tecman
  • 1,441

2 Answers2

8

PNG is always compressed by DEFLATE algorithm, as mandated by PNG specification. This is same algorithm used by zip compressor, among others.

There are no lossy compression algorithms for PNGs. PNG is always loseless.

Disclaimer: There are methods of "optimizing" PNG size by decreasing quality (color depth) of an image before saving it as PNG. This has nothing to do with PNG itself and cannot be reliably detected neither in PNG nor the original file.

Agent_L
  • 1,790
2

Estimating compression ratio of any image file is actually pretty simple. You have to know the width, height and bit depth of the image. To calculate how much data would be needed by uncompressed raw image data you have to do this simple thing: raw data size = image width * image heigth * (bits per pixel / 8). Then just divide raw data size by your PNG's file size by and you have the estimated compression ratio (not exact value because of the headers, etc.). For example 640x480x32 image would need 640 * 480 * (32 / 8) which is 1 273 800 bytes. Now lets assume your PNG has 200kB. You divide (200 * 1024) / 1273800. That gives you a compression ratio of about 0.16.

And remember about one fact. Sometimes 24 bit images are actually stored as 32 bit value. So you have to take that into account.

pvc
  • 399