genanki icon indicating copy to clipboard operation
genanki copied to clipboard

Genanki-generated deck is twice as heavy as it should be

Open skunne opened this issue 2 years ago • 1 comments

Description I created a deck with genanki. The .apkg file weighs 152kB. Then I imported this deck into Anki Desktop, and exported it again. The resulting .apkg file weighs 69kB.

As far as I can tell, the two decks are identical, but the one that went through Anki Desktop is less than half the weight of the one created directly with genanki.

Is there a way to make the deck lighter automatically, using only genanki?

genanki version 0.13.0

Additional context I reproduced the issue with a few other similar decks, ranging from 120 to 180kB when created with genanki, and ranging from 67kB to 80kB after import/export through Anki Desktop. Those are text-only decks, no media, with about 100 cards per deck, 3 fields per note, 1 card per note.

skunne avatar May 17 '23 09:05 skunne

If you run strings or a hexdump against a genanki made deck vs an app exported deck, you'll find that geanki's data output is clear-text while Anki's is not, and therefore undergoes some sort of encoding/compression.

I haven't looked into Anki's source code too much, but I see calls to zstd and Zip

Indeed when I re-export my genanki deck using mobile app (linux desktop anki app locks up when exporting...), it is about 83% smaller. When I run gzip, zstd, or zip on my geanki deck it is compressed by 89%

wamsachel avatar Jul 22 '23 17:07 wamsachel