photopea / UPNG.js

Fast and advanced PNG (APNG) decoder and encoder (lossy / lossless)
MIT License
2.1k stars 259 forks source link

Output PNG file size not deterministic #86

Closed varun-raghavendra closed 1 year ago

varun-raghavendra commented 1 year ago

I'm using UPNG.encode and I'm finding that it produces a different file size for 2 TIFF files with similar resolution. UTIF.decodeImage was done on both images to get RGBA arrays for both.

Why this disparity is there?

Also, what is the zlib compression level used by UPNG.encode? Is there a way to tweak this?

photopea commented 1 year ago

The PNG image below is also 4K (3840x2160 pixels), but it is 0.001MB. It is 12 thousand times smaller than your PNG files, while having the same resolution.

Compression usually tries to describe the file with as few bytes as possible. A smaller file usually means that it contains "less information".

The upper limit is 3 Bytes per pixel. So a 4K PNG image is never bigger than 24.9 MB.

We dont use the Zlib library for the PNG compression.

photopea commented 1 year ago

dwsample-tiff-4k