Prototype of EPUB optimization attached to this post. Optimizes the book’s ZIP container as well as contained PNG, JPG, SVG, XML, … seems to gain 5–10% on ordinary books.
I can’t test the optimization reliably. There is a program called epubcheck, but I have some trouble setting it up. Will do this soon.
The main problem with EPUB is the harsh restrictions on the ZIP container. The first file in the archive must be called mimetype and it must be uncompressed. Both requirements are hard to carry through the toolchain; for example, 7-Zip sorts files in ZIP archives by filename – no matter the command line, even breaking it into two steps doesn’t change this.
I eventually settled with renaming mimetype to !!!!!!!!, a filename that will most likely be first. After all compression is done, I can use 7-Zip’s rename command to change the name back to mimetype – and this keeps the original file order. Then I overwrite the file in the archive via 7-Zip’s add, without compression. To my surprise, this also keeps the original order.
On the command line, it’s something like
Code:
7z rn foo.zip !!!!!!!! mimetype
7z a foo.zip mimetype -mm=Deflate -m0=Copy -mtc=off -mcl=off -mcu=off
I’d be glad about feedback, considering especially that I can’t use the verification tool yet and my wife’s ebook reader is broken.