Expand description
Pure-Rust DjVu decoder written from the DjVu v3 public specification.
This crate implements the full DjVu v3 document format in safe Rust, including IFF container parsing, JB2 bilevel decoding, IW44 wavelet decoding, BZZ decompression, text layer extraction, and annotation parsing. All algorithms are written from the public DjVu spec with no GPL code.
§Key public types
DjVuError— top-level error enum (wrapsIffError, etc.)IffError— errors from the IFF container parserPageInfo— page metadata parsed from the INFO chunkRotation— page rotation enum (None, Ccw90, Rot180, Cw90)DjVuDocument— high-level document model (IFF/BZZ/IW44 based)DjVuPage— lazy page handleDjVuBookmark— NAVM bookmark (table of contents)DocError— error type for the document modeldjvu_render::RenderOptions— render parametersdjvu_render::RenderError— render pipeline error typetext::TextLayer— text layer from TXTz/TXTa chunkstext::TextZone— a zone node in the text layer hierarchyannotation::Annotation— page-level annotationannotation::MapArea— clickable area with URL and shapePixmap— RGBA pixel buffer returned by render methodsBitmap— 1-bit bitmap for JB2 mask layersDocument— owned DjVu document (high-level std API, requires std feature)Page— a page within aDocument
§Quick start
use djvu_rs::Document;
let doc = Document::open("file.djvu").unwrap();
println!("{} pages", doc.page_count());
let page = doc.page(0).unwrap();
println!("{}x{} @ {} dpi", page.width(), page.height(), page.dpi());
let pixmap = page.render().unwrap();
// pixmap.data: RGBA bytes§IFF parser
use djvu_rs::iff::parse_form;
let data = std::fs::read("file.djvu").unwrap();
let form = parse_form(&data).unwrap();
println!("form type: {:?}", std::str::from_utf8(&form.form_type));Re-exports§
pub use error::BzzError;pub use error::DjVuError;pub use error::IffError;pub use error::Iw44Error;pub use error::Jb2Error;pub use djvu_document::DjVuBookmark;pub use djvu_document::DjVuDocument;pub use djvu_document::DjVuPage;pub use djvu_document::DocError;pub use error::LegacyError as Error;
Modules§
- annotation
- Annotation parser for DjVu ANTz/ANTa chunks — phase 4.
- bzz_new
- BZZ decompressor — clean-room implementation.
- djvu_
async - Async render surface for
DjVuPage— phase 5 extension. - djvu_
document - New document model — phase 3.
- djvu_
render - Rendering pipeline for
DjVuPage— phase 5. - error
- Typed error hierarchy for the new implementation (phase 1).
- iff
- IFF container parser (phase 1, written from spec). IFF (Interchange File Format) container parser for DjVu files.
- image_
compat image::ImageDecoderintegration — allows DjVu pages to be used as first-class image sources in theimagecrate ecosystem.- iw44_
new - IW44 wavelet image decoder — clean-room implementation (phase 2c).
- jb2_new
- JB2 bilevel image decoder — clean-room implementation (phase 2b).
- metadata
- Document metadata parser for METa/METz chunks — phase 4 extension.
- ocr_
export - hOCR and ALTO XML export for the text layer.
- DjVu to PDF converter — phase 6.
- text
- Text layer parser for DjVu TXTz/TXTa chunks — phase 4.
- tiff_
export - DjVu to TIFF exporter — phase 4 format extension.
Structs§
- Bitmap
- A 1-bit-per-pixel packed bitmap image.
- Bookmark
- A bookmark entry from the NAVM chunk (table of contents).
- Document
- A parsed DjVu document. Owns the parsed structure.
- Gray
Pixmap - An 8-bit grayscale image, 1 byte per pixel.
- Page
- A page within a DjVu document.
- Page
Info - Metadata from the INFO chunk of a DjVu page.
- Pixmap
- An RGBA pixel image, 4 bytes per pixel.
- Text
Layer - The text layer of a DjVu page (from TXTz or TXTa chunks).
- Text
Zone - A text zone with bounding box and text span within the page text.
Enums§
- Rotation
- Page rotation encoded in INFO flags bits 0–1.
- Text
Zone Kind - Text zone type in the DjVu text layer hierarchy.