Bug 464710 - Support opening .kra files bzip2 compressed
Summary: Support opening .kra files bzip2 compressed
Status: REPORTED
Alias: None
Product: krita
Classification: Applications
Component: File formats (show other bugs)
Version: git master (please specify the git hash!)
Platform: Other Other
: NOR wishlist
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-23 18:45 UTC by Brunoais
Modified: 2023-01-23 21:16 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Values to prove the point (465 bytes, text/plain)
2023-01-23 18:45 UTC, Brunoais
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brunoais 2023-01-23 18:45:56 UTC
Created attachment 155537 [details]
Values to prove the point

WHAT:
Request to add support for .kra files which are compressed with bzip2.

Proof-in-point it's better:
Bzip2 objectively supports higher compression rates than the deflate algorithm which would help reducing the size of .kra files for archival purposes.
However, bzip2 is much slower than deflate. Most people wouldn't want to use it for saving while modifying the file. However, for archival, some people may not mind the extra time in exchange for better compression.

Tests prove the higher compression (and also sources):
https://archive.is/A5GsW
https://tukaani.org/lzma/benchmarks.html (https://archive.is/HJgj)

Values to prove the point: See the attachment (anti-spam block)

What Krita needs to do (in concrete) to fulfill this ticket:

Update quazip dependency to version 1.4. (https://github.com/stachenov/quazip/releases/tag/v1.4)

Non-issues for this ticket:
Support saving kra files as bzip2. That will be handled by a different ticket.
Comment 1 amyspark 2023-01-23 20:36:20 UTC
Hi!

It's an interesting thing to do for sure. However, I believe the real problem is that the tests you showed do not apply to KRA; the biggest contribution is made by pixel layers, which are binary and of much higher entropy than a .txt.

I'd be glad to see if other algorithms (Zstandard, LZMA2, gzip, etc.)  are more suitable for this case; and having multithreaded compression would certainly help a lot, irrespective of whether we change the algorithm.
Comment 2 Brunoais 2023-01-23 21:16:25 UTC
(In reply to amyspark from comment #1)
> I'd be glad to see if other algorithms (Zstandard, LZMA2, gzip, etc.)  are
> more suitable for this case; and having multithreaded compression would
> certainly help a lot, irrespective of whether we change the algorithm.

The only alternative I can see would be changing libraries from quazip to, for example, minizip-ng. However, that would be much much more work. 
But the gain would be being able to use more effective compression algorithms such as Zstd you mention or LZMA.

Given just changing quazip is a quick-win, backwards-compatible, just changing the version used and it provides marginally better compression, I think it should be worth as a quick-win.

If you need actual tests with kra files, I can try finding open-source ones and test compression with (unless you can provide some data to test on)