Different sizes of PNG

Ask for help and post your question on how to use XnView Classic.

Moderators: XnTriq, helmut, xnview

User avatar
XnTriq
Moderator & Librarian
Posts: 6402
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Different sizes of PNG

Post by XnTriq »

cday wrote: Sat Oct 28, 2023 8:21 pmA pity that PNG compression level isn't displayed in the XnView MP file properties display, do you think that the value could be determined and possibly added?
I found this post by the late Glenn Randers-Pehrson:
https://www.superuser.com/questions/1124701/is-it-possible-to-retrieve-the-compression-level-from-a-png-image#1125041 wrote:According to the zlib specification (RFC-1950), the zlib datastream within a PNG file contains a two-bit "FLEVEL" flag:

Code: Select all

FLEVEL (Compression level)
These flags are available for use by specific compression methods.
The "deflate" method (CM = 8) sets these flags as follows:

    0 - compressor used fastest algorithm [levels 0, 1]
    1 - compressor used fast algorithm    [levels 2-5]
    2 - compressor used default algorithm [level 6]
    3 - compressor used maximum compression, slowest algorithm [levels 7-9]
pngcheck checks FLEVEL and reports it like this:

Code: Select all

pngcheck -v rose.png
[...]
chunk IDAT at offset 0x00073, length 6742
  zlib: deflated, 16K window, maximum compression
While this won't distinguish among all 10 possible compression levels, it could be the basis for creating a libpng png_get_compression_level() function that would at least tell you something.

pngcheck -v test22ps.png → “superfast compression”/“-0.7% compression”:

Code: Select all

File: test22ps.png (3100615 bytes)
  chunk IHDR at offset 0x0000c, length 13
    1173 x 875 image, 24-bit RGB, non-interlaced
  chunk pHYs at offset 0x00025, length 9: 11811x11811 pixels/meter (300 dpi)
  chunk iCCP at offset 0x0003a, length 2637
    profile name = Photoshop ICC profile, compression method = 0 (deflate)
    compressed profile = 2614 bytes
  chunk iTXt at offset 0x00a93, length 17356, keyword: XML:com.adobe.xmp
    uncompressed, no language tag
    no translated keyword, 17335 bytes of UTF-8 text
  chunk cHRM at offset 0x04e6b, length 32
    White x = 0.31269 y = 0.32899,  Red x = 0.63999 y = 0.33
    Green x = 0.3 y = 0.6,  Blue x = 0.14999 y = 0.05999
  chunk IDAT at offset 0x04e97, length 3080476
    zlib: deflated, 32K window, superfast compression
  chunk IEND at offset 0x2f4fbf, length 0
No errors detected in test22ps.png (7 chunks, -0.7% compression).
pngcheck -v test22xn.png → “default compression”/“72.3% compression”:

Code: Select all

File: test22xn.png (854428 bytes)
  chunk IHDR at offset 0x0000c, length 13
    1173 x 875 image, 24-bit RGB, non-interlaced
  chunk iCCP at offset 0x00025, length 2609
    profile name = ICC profile, compression method = 0 (deflate)
    compressed profile = 2596 bytes
  chunk pHYs at offset 0x00a62, length 9: 11811x11811 pixels/meter (300 dpi)
  chunk IDAT at offset 0x00a77, length 8192
    zlib: deflated, 32K window, default compression
  chunk IDAT at offset 0x02a83, length 8192
  chunk IDAT at offset 0x04a8f, length 8192
  chunk IDAT at offset 0x06a9b, length 8192
  chunk IDAT at offset 0x08aa7, length 8192
  chunk IDAT at offset 0x0aab3, length 8192
  chunk IDAT at offset 0x0cabf, length 8192
  chunk IDAT at offset 0x0eacb, length 8192
  chunk IDAT at offset 0x10ad7, length 8192
  chunk IDAT at offset 0x12ae3, length 8192
  chunk IDAT at offset 0x14aef, length 8192
  chunk IDAT at offset 0x16afb, length 8192
  chunk IDAT at offset 0x18b07, length 8192
  chunk IDAT at offset 0x1ab13, length 8192
  chunk IDAT at offset 0x1cb1f, length 8192
  chunk IDAT at offset 0x1eb2b, length 8192
  chunk IDAT at offset 0x20b37, length 8192
  chunk IDAT at offset 0x22b43, length 8192
  chunk IDAT at offset 0x24b4f, length 8192
  chunk IDAT at offset 0x26b5b, length 8192
  chunk IDAT at offset 0x28b67, length 8192
  chunk IDAT at offset 0x2ab73, length 8192
  chunk IDAT at offset 0x2cb7f, length 8192
  chunk IDAT at offset 0x2eb8b, length 8192
  chunk IDAT at offset 0x30b97, length 8192
  chunk IDAT at offset 0x32ba3, length 8192
  chunk IDAT at offset 0x34baf, length 8192
  chunk IDAT at offset 0x36bbb, length 8192
  chunk IDAT at offset 0x38bc7, length 8192
  chunk IDAT at offset 0x3abd3, length 8192
  chunk IDAT at offset 0x3cbdf, length 8192
  chunk IDAT at offset 0x3ebeb, length 8192
  chunk IDAT at offset 0x40bf7, length 8192
  chunk IDAT at offset 0x42c03, length 8192
  chunk IDAT at offset 0x44c0f, length 8192
  chunk IDAT at offset 0x46c1b, length 8192
  chunk IDAT at offset 0x48c27, length 8192
  chunk IDAT at offset 0x4ac33, length 8192
  chunk IDAT at offset 0x4cc3f, length 8192
  chunk IDAT at offset 0x4ec4b, length 8192
  chunk IDAT at offset 0x50c57, length 8192
  chunk IDAT at offset 0x52c63, length 8192
  chunk IDAT at offset 0x54c6f, length 8192
  chunk IDAT at offset 0x56c7b, length 8192
  chunk IDAT at offset 0x58c87, length 8192
  chunk IDAT at offset 0x5ac93, length 8192
  chunk IDAT at offset 0x5cc9f, length 8192
  chunk IDAT at offset 0x5ecab, length 8192
  chunk IDAT at offset 0x60cb7, length 8192
  chunk IDAT at offset 0x62cc3, length 8192
  chunk IDAT at offset 0x64ccf, length 8192
  chunk IDAT at offset 0x66cdb, length 8192
  chunk IDAT at offset 0x68ce7, length 8192
  chunk IDAT at offset 0x6acf3, length 8192
  chunk IDAT at offset 0x6ccff, length 8192
  chunk IDAT at offset 0x6ed0b, length 8192
  chunk IDAT at offset 0x70d17, length 8192
  chunk IDAT at offset 0x72d23, length 8192
  chunk IDAT at offset 0x74d2f, length 8192
  chunk IDAT at offset 0x76d3b, length 8192
  chunk IDAT at offset 0x78d47, length 8192
  chunk IDAT at offset 0x7ad53, length 8192
  chunk IDAT at offset 0x7cd5f, length 8192
  chunk IDAT at offset 0x7ed6b, length 8192
  chunk IDAT at offset 0x80d77, length 8192
  chunk IDAT at offset 0x82d83, length 8192
  chunk IDAT at offset 0x84d8f, length 8192
  chunk IDAT at offset 0x86d9b, length 8192
  chunk IDAT at offset 0x88da7, length 8192
  chunk IDAT at offset 0x8adb3, length 8192
  chunk IDAT at offset 0x8cdbf, length 8192
  chunk IDAT at offset 0x8edcb, length 8192
  chunk IDAT at offset 0x90dd7, length 8192
  chunk IDAT at offset 0x92de3, length 8192
  chunk IDAT at offset 0x94def, length 8192
  chunk IDAT at offset 0x96dfb, length 8192
  chunk IDAT at offset 0x98e07, length 8192
  chunk IDAT at offset 0x9ae13, length 8192
  chunk IDAT at offset 0x9ce1f, length 8192
  chunk IDAT at offset 0x9ee2b, length 8192
  chunk IDAT at offset 0xa0e37, length 8192
  chunk IDAT at offset 0xa2e43, length 8192
  chunk IDAT at offset 0xa4e4f, length 8192
  chunk IDAT at offset 0xa6e5b, length 8192
  chunk IDAT at offset 0xa8e67, length 8192
  chunk IDAT at offset 0xaae73, length 8192
  chunk IDAT at offset 0xace7f, length 8192
  chunk IDAT at offset 0xaee8b, length 8192
  chunk IDAT at offset 0xb0e97, length 8192
  chunk IDAT at offset 0xb2ea3, length 8192
  chunk IDAT at offset 0xb4eaf, length 8192
  chunk IDAT at offset 0xb6ebb, length 8192
  chunk IDAT at offset 0xb8ec7, length 8192
  chunk IDAT at offset 0xbaed3, length 8192
  chunk IDAT at offset 0xbcedf, length 8192
  chunk IDAT at offset 0xbeeeb, length 8192
  chunk IDAT at offset 0xc0ef7, length 8192
  chunk IDAT at offset 0xc2f03, length 8192
  chunk IDAT at offset 0xc4f0f, length 8192
  chunk IDAT at offset 0xc6f1b, length 8192
  chunk IDAT at offset 0xc8f27, length 8192
  chunk IDAT at offset 0xcaf33, length 8192
  chunk IDAT at offset 0xccf3f, length 8192
  chunk IDAT at offset 0xcef4b, length 6717
  chunk IEND at offset 0xd0994, length 0
No errors detected in test22xn.png (108 chunks, 72.3% compression).
User avatar
Ty
Posts: 152
Joined: Thu Feb 23, 2006 3:18 am
Location: San Luis Obispo, California

Re: Different sizes of PNG

Post by Ty »

Thanks cday and Triq for your help, comments, insights and efforts.

Now that you've dug into the matter and provided the answer, I guess it should have been obvious all along. And should have been the first thing to investigate.

Compression.

XnView apparently saves PNG files with (a) a high level of compression, and (b) without asking--at least by default. In Photoshop, one is forced to choose a compression level, and I was using "none" without really thinking about it.

So of course the files were huge, compared to the Xn versions. When I saved the big TIF file to PNG in Photoshop using maximum compression, what had been 18MB was about the same (actually a little smaller) as the 3.3MB Xn version.

Anyway, problem solved / issue understood. Thanks again for your help. 
cday
XnThusiast
Posts: 4228
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Different sizes of PNG

Post by cday »

In Windows, PNG compression level can be set using the Options button in the Save menu... :D

In Linux, the file compression level can be set in the viewer using File > Format settings > Write tab -- PNG.
User avatar
XnTriq
Moderator & Librarian
Posts: 6402
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Different sizes of PNG

Post by XnTriq »

I converted the sample file provided by Ty from TIFF to PNG with a bunch of different applications:

Code: Select all

┌────────────────────────┬──────────────────┬──────────┬─────────────────┬──────┬──────┬──────┬────────────────────┐
│ Software               │ Command          │ Filesize │   Compression   │ ICC  │ EXIF │ XMP  │ Additional Chunks  │
├────────────────────────┼──────────────────┼──────────┼─────────────────┼──────┼──────┼──────┼────────────────────┤
│ XnView Classic v2.51.5 │ Save As = Export │  847.170 │ maximum / 72.5% │      │      │      │ pHYs               │
│ XnView MP v1.6.1       │ Save As          │  864.456 │ maximum / 71.9% │ iCCP │ eXIf │ iTXt │ pHYs               │
│ XnView MP v1.6.1       │ Export           │  847.170 │ maximum / 72.5% │      │      │      │ pHYs               │
│ Adobe Photoshop CS2    │ Save As          │  847.237 │ maximum / 72.5% │ iCCP │      │      │ pHYs + gAMA + cHRM │
│ Adobe Photoshop CS2    │ Save For Web     │  895.382 │ maximum / 70.9% │      │      │      │        gAMA + tEXt │
│ GIMP v2.10.34          │ Export As        │  864.875 │ maximum / 71.9% │ iCCP │ zTXt │ iTXt │                    │
│ Corel Photo-Paint X6   │ Save As = Export │  905.543 │ default / 70.6% │ iCCP │      │      │ pHYs               │
└────────────────────────┴──────────────────┴──────────┴─────────────────┴──────┴──────┴──────┴────────────────────┘
The PNGs are available for download: t46337.zip

With the exception of photoshop_save-as.png, all files were identical once PngOptimizer was done with them:

Code: Select all

Optimizing xnview-classic.png         (OK) 847.170 bytes → 845.889 bytes (99% of the original size)
Optimizing xnview-mp_save-as.png      (OK) 864.456 bytes → 845.889 bytes (97% of the original size)
Optimizing xnview-mp_export.png       (OK) 847.170 bytes → 845.889 bytes (99% of the original size)
Optimizing photoshop_save-as.png      (OK) 847.237 bytes → 844.507 bytes (99% of the original size)
Optimizing photoshop_save-for-web.png (OK) 895.382 bytes → 845.889 bytes (94% of the original size)
Optimizing gimp.png                   (OK) 864.875 bytes → 845.889 bytes (97% of the original size)
Optimizing photopaint.png             (OK) 905.543 bytes → 845.889 bytes (93% of the original size)