optibook is a Bash script that will try to optimize the size of ePub files (.epub) and comic book archives (.cbz, .cbr).
It combines several optimizations to help reduce the size of eBook files:
- Lossless optimization of JPEG, PNG and SVG images
- Minification of CSS and HTML files
- Embedded font optimization by subsetting the glyphs to the characters used in the eBook
- Better overall compression by taking advantage of 7-Zip more efficient Zip implementation to recompress the files
- Optional JPEG artifact reduction using the Waifu2x algorithm and lossy recompression of images from comic book archives to the more efficient WebP and AVIF formats
It can typically reduce the size of eBooks by up to 40% depending on the source.
To losslessly optimize comic book archives or books:
./optibook.sh FILE1 [FILE2 ...]
To recompress comic book archives to WebP while applying while applying light denoising to reduce JPEG artifacts:
./optibook.sh -r webp -n 1 FILE1 [FILE2 ...]
Same thing using the AVIF file format:
./optibook.sh -r avif -n 1 FILE1 [FILE2 ...]
Complete syntax can be obtained by running optibook without argument.
- Bash
- p7zip ≥ 9.38
- jpegtran from mozjpeg (recommended), libjpeg-turbo or libjpeg
- OptiPNG
- svgcleaner
- Python
- html2text
- fonttools
- minify
- cwebp from libwebp
- waifu2x-ncnn-vulkan
- avifenc from libavif
- GNU parallel to boost performance