prensa 0.4.0

Optimize EPUBs for e-ink readers
Documentation

prensa

The engine behind the prensa CLI: optimize EPUBs for e-ink readers. It removes embedded fonts, fits images to the screen in grayscale, rewrites progressive JPEGs as baseline and converts images the reader cannot show (WebP, BMP, images embedded in chapters), producing a smaller, standard EPUB that is easier on small devices. Wide diagrams can optionally be turned to fill the screen's height.

Defaults are tuned on an Xteink X4 Pro running the CrossPoint firmware. See the repository for before/after photos and details.

use std::fs::File;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let input = File::open("book.epub")?;
    let output = File::create("book-optimized.epub")?;
    let report = prensa::optimize(input, output, &prensa::Options::default())?;

    println!("{} image(s) optimized", report.images_changed);
    Ok(())
}

optimize works on any Read + Seek input and Write + Seek output, never prints and returns a Report. Use optimize_with_progress to drive a progress bar.

Errors are a prensa::Error: InvalidZip, Malformed { entry, .. } (an entry that must be rewritten could not be parsed) or Io. optimize writes straight to output; write to a temporary file and rename it if you need atomic writes.

Enable the parallel feature to optimize images on all cores (the CLI does); the output is the same either way.