Takes blueprint PDFs and images, extracts raster data, optionally geo-references it, and generates tile pyramids (DeepZoom, XYZ) suitable for web-based viewers. Inspired by libvips, built from scratch.
Features
- PDF extraction — extract embedded raster images from scanned blueprint PDFs via lopdf (zero runtime dependencies)
- PDF rendering — render vector PDFs (AutoCAD exports, text, paths) via PDFium, with optional memory-budgeted rendering
- Image decoding — JPEG, PNG, TIFF via the
imagecrate - Tile pyramid generation — multi-threaded engine with backpressure, configurable tile size and overlap
- Layout formats — DeepZoom (
.dzi+ directory tree) and XYZ (z/x/y) - Tile encoding — PNG, JPEG (configurable quality), or raw pixel output
- Blank tile optimization — emit full tiles or write 1-byte placeholders for uniform-color regions
- Edge tile background — configurable background color for padding partial tiles at image edges
- Geo-referencing — affine transform mapping pixel coordinates to geographic coordinates, GCP support
- Observability — progress events, per-level callbacks, peak memory tracking
Quick Start
use libviprs::{
extract_page_image, generate_pyramid, BlankTileStrategy,
EngineConfig, FsSink, Layout, PyramidPlanner, TileFormat,
};
use std::path::Path;
// Extract raster from a scanned blueprint PDF
let raster = extract_page_image(Path::new("blueprint.pdf"), 1).unwrap();
// Plan the pyramid
let planner = PyramidPlanner::new(
raster.width(), raster.height(),
256, 0, Layout::DeepZoom,
).unwrap();
let plan = planner.plan();
// Generate tiles to disk
let sink = FsSink::new("output_tiles", plan.clone(), TileFormat::Png);
let config = EngineConfig::default()
.with_concurrency(4)
.with_blank_tile_strategy(BlankTileStrategy::Placeholder);
let result = generate_pyramid(&raster, &plan, &sink, &config).unwrap();
println!(
"{} tiles across {} levels ({} blank tiles skipped)",
result.tiles_produced, result.levels_processed, result.tiles_skipped,
);
Modules
| Module | Description |
|---|---|
source | Image decoding (JPEG, PNG, TIFF) into canonical Raster |
pdf | PDF parsing (lopdf) and optional rendering (PDFium) |
raster | Pixel buffer, region views, format normalization |
pixel | Pixel format definitions (Gray8, RGB8, RGBA8, 16-bit) |
planner | Tile math, level computation, layout generation |
resize | Downscaling for pyramid levels |
engine | Multi-threaded tile extraction with backpressure |
sink | Tile output (filesystem, memory, slow sink for testing) |
geo | Affine geo-transform, GCP solving, bounding box |
observe | Progress events, memory tracking |
Requirements
- Rust 1.85+ (edition 2024)
- libpdfium shared library (only if using the
pdfiumfeature)
Related Crates
| Crate | Description |
|---|---|
libviprs-cli | Command-line interface (viprs binary) |
libviprs-tests | Integration tests and fixtures |