Why do these PNG images differ so much in size?

4

0

I created a lot of tiles and each of my tiles is less than 2 KB except one which is 16.2 KB. It is very similar to another tile I created which is 1.48 KB. Yes, I'm nitpicking about the sizes here but I find it strange that a similar file using the same amount of different colors as the others is more then 10 times as big.

enter image description here 16.4KB

enter image description here 1.48KB

Neither have transparency and both use PNG24. I batch exported all layers using the same settings. Later I tried saving the larger file manually which resulted in a slightly greater file size. I would even expect the bottom image to be slightly larger since it has more contrasting pixels making it more difficult to compress the clusters.

Madmenyo

Posted 2016-03-08T09:53:09.220

Reputation: 800

1This is very interesting. I'd like to know how this could have happened. It definitely isn't related to the contents or resolution or anything like that, this is caused by the software handling the compression (e.g. photoshop). the question is whether it's a bug or if it's intentional. – Cestarian – 2016-03-08T18:56:05.967

For the person who edited my post, thank you. But you are wrong on kB, it's with a capital K since it's not your standard 1000's prefix it stands for 1024 and the uppercase was introduced a long time ago when bits where introduced. – Madmenyo – 2016-03-08T22:32:13.340

Answers

2

While I can't pinpoint the exact reason why this is happening on your end I think Photoshop can have this issue for multiple reasons. I remember previously reading that Photoshop sometimes also saves a thumbnail of the image inside the image file itself for performance reasons. Might be the case here maybe. Another possibility is that Photoshop internally used different mechanisms to save the image and Photoshop doesn't always compress to the maximum.

I ran both your images via PNG Crush - http://pngcrush.com/ - to minimize their size as much as possible and downloaded them back and both of them, while different in size, got around 1kb.

Hope this helps.

Mario Awad

Posted 2016-03-08T09:53:09.220

Reputation: 146

1

The larger image contains a 15204-byte iTXt chunk containing some Adobe metadata. The smaller image also contains a similar chunk but it's smaller, only 866 bytes. As Mario's answer says, you can use pngcrush to remove it.

Get "pngcheck" and run "pngcheck -v file.png" to find out what's in the file.

The 16.4KB file:

$ pngcheck -v 6*
File: 6iutM.png (16643 bytes)
  chunk IHDR at offset 0x0000c, length 13
    32 x 64 image, 8-bit palette, non-interlaced
  chunk pHYs at offset 0x00025, length 9: 2835x2835 pixels/meter (72 dpi)
  chunk iTXt at offset 0x0003a, length 15204, keyword: XML:com.adobe.xmp
    uncompressed, no language tag
    no translated keyword, 15183 bytes of UTF-8 text
  chunk cHRM at offset 0x03baa, length 32
    White x = 0.31269 y = 0.32899,  Red x = 0.63999 y = 0.33001
    Green x = 0.3 y = 0.6,  Blue x = 0.15 y = 0.05999
  chunk PLTE at offset 0x03bd6, length 768: 256 palette entries
  chunk tRNS at offset 0x03ee2, length 7: 7 transparency entries
  chunk IDAT at offset 0x03ef5, length 506
    zlib: deflated, 32K window, maximum compression
  chunk IEND at offset 0x040fb, length 0
No errors detected in 6iutM.png (8 chunks, -712.6% compression).

The 1.52KB file:

$ pngcheck -v 7*
File: 7W95m.png (1523 bytes)
  chunk IHDR at offset 0x0000c, length 13
    32 x 64 image, 8-bit palette, non-interlaced
  chunk tEXt at offset 0x00025, length 25, keyword: Software
  chunk iTXt at offset 0x0004a, length 886, keyword: XML:com.adobe.xmp
    uncompressed, no language tag
    no translated keyword, 865 bytes of UTF-8 text
  chunk PLTE at offset 0x003cc, length 21: 7 palette entries
  chunk IDAT at offset 0x003ed, length 498
    zlib: deflated, 32K window, maximum compression
  chunk IEND at offset 0x005eb, length 0
No errors detected in 7W95m.png (6 chunks, 25.6% compression).

Glenn Randers-Pehrson

Posted 2016-03-08T09:53:09.220

Reputation: 477