Skip to main content

Crate djvu_rs

Crate djvu_rs 

Source
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

§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::ImageDecoder integration — allows DjVu pages to be used as first-class image sources in the image crate 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.
pdf
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.
GrayPixmap
An 8-bit grayscale image, 1 byte per pixel.
Page
A page within a DjVu document.
PageInfo
Metadata from the INFO chunk of a DjVu page.
Pixmap
An RGBA pixel image, 4 bytes per pixel.
TextLayer
The text layer of a DjVu page (from TXTz or TXTa chunks).
TextZone
A text zone with bounding box and text span within the page text.

Enums§

Rotation
Page rotation encoded in INFO flags bits 0–1.
TextZoneKind
Text zone type in the DjVu text layer hierarchy.