Skip to main content

Crate prensa

Crate prensa 

Source
Expand description

Optimize EPUBs for e-ink readers.

The engine works on any reader/writer pair, so it does not care whether the book comes from a file, memory or (later) a browser. Front ends such as the prensa CLI handle paths, atomic writes and printing.

use std::fs::File;

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);

§Features

  • parallel (off by default): optimize images on all cores with rayon. The output is identical either way. Off by default so the library adds no threads where they are unavailable, such as WebAssembly in the browser.

Structs§

Options
Optimization settings, always valid.
OptionsBuilder
Builds an Options. Settings not given keep their default.
Progress
Where optimize_with_progress is in the book.
Report
What optimize did to the book.
Warning
A problem that did not stop the book. Display gives entry: message.

Enums§

Device
An e-reader prensa has a profile for.
Error
Why optimize failed.
InvalidOptions
Why OptionsBuilder::build refused the settings.
Rotation
Which way wide images are turned to fill a portrait screen.

Functions§

optimize
Read an EPUB from input and write an optimized copy to output.
optimize_with_progress
Like optimize, calling on_progress before each entry is processed.

Type Aliases§

Source
Boxed cause of an Error. Boxing keeps the crates prensa uses internally (zip, quick-xml) out of the public API, so upgrading them is not a breaking change.