PNG compression

Questions and comments about Other World Mapper.

Moderator: Kanchou

User avatar
Balmung
Posts: 131
Joined: Sun Mar 28, 2021 2:12 pm
Location: Germany

Re: PNG compression

Post by Balmung » Thu Jun 24, 2021 12:35 pm

Maybe I'm a little bit lost in translation, but ... is the Linux version of OWM now better for exports or not?

nDervish
Posts: 85
Joined: Sat Nov 15, 2014 12:18 am

Re: PNG compression

Post by nDervish » Fri Jun 25, 2021 7:58 am

Assuming you're talking about file sizes/compression...

I just used OWM 1.0.4 to open the same existing map file in both Linux and Windows, then exported from each with the default PNG export settings. The Windows export is approximately 10% larger (6 528 930 bytes Linux, 7 251 973 bytes Windows). With a quick visual comparison, it appears that alpha-blended objects are slightly darker/less transparent on the Linux version. Bitmapped features are significantly clearer on the Windows version, while their lines are slightly blurred on the Linux version, which is probably why the Linux version is smaller. Based on this, I'd say Windows for better quality, Linux for smaller file sizes, although they really are pretty much the same overall.

But, of course, YMMV depending on the specific PNG library and library version you have installed.

User avatar
Kanchou
Site Admin
Posts: 934
Joined: Mon Nov 10, 2014 2:23 pm

Re: PNG compression

Post by Kanchou » Tue Jun 29, 2021 4:03 pm

Final raster is done via Cairo in Linux so the alpha blending is a tiny little bit different. The creation of the png is different as well but that's something we could change down the road by adding the ability to change the (lossless) compression mode.

Though I would say nowadays most people aren't as concerned with image size :)

- Alejandro
Alejandro S. Canosa
Three Minds Software

User avatar
Balmung
Posts: 131
Joined: Sun Mar 28, 2021 2:12 pm
Location: Germany

Re: PNG compression

Post by Balmung » Tue Jun 29, 2021 4:32 pm

As long as a map cannot be exported as a PDF, even 1TB for a DIN-A0 map would be okay, if it means I got absolute zero compression or at least the lowest possible ;)

nDervish
Posts: 85
Joined: Sat Nov 15, 2014 12:18 am

Re: PNG compression

Post by nDervish » Wed Jun 30, 2021 7:35 am

Not sure why you actively want larger files. Are you post-processing with tools that don't understand PNG format?

Image quality is not an issue here. PNG is a lossless compression algorithm, just like a ZIP archive. If you PNG compress an image and then re-render it from the compressed PNG file, the result will (barring bugs in the PNG library) be bit-for-bit identical to the original.

Proof:

I opened GIMP, created a new 1920x1080 image, and ran a "lava" render to fill it, then exported an uncompressed copy as A-Original.raw and a PNG-compressed copy as B-Compressed.png. After doing the exports, I exited GIMP, started a fresh GIMP session, loaded B-Compressed.png, and exported a third copy of the image as C-Reconstructed.raw.
~/Documents$ ls -l A-Original.raw B-Compressed.png C-Reconstructed.raw
-rw-r--r-- 1 me me 8294400 Jun 30 13:23 A-Original.raw
-rw-r--r-- 1 me me 2268371 Jun 30 13:23 B-Compressed.png
-rw-r--r-- 1 me me 8294400 Jun 30 13:24 C-Reconstructed.raw
Note that the file size of 8294400 on the .raw files is equal to 1920*1080*4, providing further confirmation that they are uncompressed.

Finally, I generated MD5 hashes for the two .raw files and ran a binary diff of the files:
~/Documents$ md5sum A-Original.raw C-Reconstructed.raw
dd66b8b08ff993812288875a5c083231 A-Original.raw
dd66b8b08ff993812288875a5c083231 C-Reconstructed.raw
~/Documents$ diff -b A-Original.raw C-Reconstructed.raw
~/Documents$
The original and reconstructed raw images are 100% identical. PNG compression does not alter the content of the image in any way.

User avatar
Balmung
Posts: 131
Joined: Sun Mar 28, 2021 2:12 pm
Location: Germany

Re: PNG compression

Post by Balmung » Wed Jun 30, 2021 12:50 pm

I don't want larger files - I just don't care if they are large ;)

I attached an Inkscape-SVG with some lines to demonstate my thoughts.

Open it with Inkscape and export it with this settings:

- 300 dpi
- Z_NO_COMPRESSION
- CAIRO_ANTIALIAS_BEST

The file size is ~545MB with only some black lines.
At compression level 1 it shrinks to ~4MB.

When I export my OWM map, with a lot more going on, the exported PNG is ~60MB in size.

So my guess is, that some compression is happening. Maybe it's something with Windows 10 or the Windows version of Inkscape or the Windows version of OWM - I really don't know. That's why I asked the developers and got some answers, like:
Kanchou wrote:
Fri Apr 09, 2021 10:24 am
In Linux/OSX libpng does the encoding of the png export and it must be doing (lossless) compression by default.

In Windows we don't have control over it.
and
Kanchou wrote:
Tue Jun 29, 2021 4:03 pm
Final raster is done via Cairo in Linux so the alpha blending is a tiny little bit different. The creation of the png is different as well but that's something we could change down the road by adding the ability to change the (lossless) compression mode.
So it seems, that the Windows version of Inkscape is using Cairo for PNG exports, just like OWM - but the Windows version of OWM uses a different library. Maybe it's just that and the only thing I have to do is using Linux to export my map when the work is done.
Attachments
lines.zip
(21.38 KiB) Downloaded 32 times

Post Reply