Expand description
A library to generate multi-resolution cubemap tiles and Pannellum-compatible configurations from equirectangular or cylindrical panoramas.
§Overview
panorama-tiler processes a single stitched panorama image into:
- Six cubemap face images (
front,back,up,down,left,right). - A multi-resolution pyramid containing cropped tile segments at configurable zoom levels.
- A JSON configuration file (
config.json) mapped directly to Pannellum’s configuration format.
§Feature Flags
metadata(Enabled by default): Enables automatic projection angle and crop detection using XMP and EXIF tags.webp(Enabled by default): Adds support for encoding tile output in the WebP format.
§Examples
§Automatic Metadata Processing
If the source panorama contains valid EXIF or GPano XMP tags, you can process the image with
automatic angle extraction:
use panorama_tiler::{OutputConfig, OutputFormat, tile_panorama_with_guessed_angles};
use std::path::Path;
fn main() -> Result<(), panorama_tiler::TilerError> {
let input = Path::new("input_photosphere.jpg");
let output = Path::new("tiles_output");
let config = OutputConfig {
format: OutputFormat::Webp,
quality: 85,
..Default::default()
};
tile_panorama_with_guessed_angles(input, output, Some(config))?;
Ok(())
}§Manual Configuration Processing
If metadata tags are absent, parameters can be passed manually:
use panorama_tiler::{
TilerConfig, PanoAngles, OutputConfig, Projection, OutputFormat, tile_panorama
};
use std::path::Path;
fn main() -> Result<(), panorama_tiler::TilerError> {
let config = TilerConfig {
angles: PanoAngles {
haov: 180.0,
vaov: 90.0,
projection: Projection::Cylindrical,
..Default::default()
},
output: OutputConfig {
tile_size: 512,
format: OutputFormat::Jpeg,
quality: 85,
..Default::default()
},
};
tile_panorama(
Path::new("input_pano.jpg"),
Path::new("tiles_output"),
&config,
)?;
Ok(())
}Modules§
Structs§
- Fallback
Item - A representation of a fallback cube face tile.
- Generated
Tiles - Container holding the raw outputs of the multi-resolution pipeline.
- Multi
ResConfig - Output
Config - Pannellum
Config - Pano
Angles - Tile
Item - A representation of an individual generated tile.
- Tiled
Panorama Output - Tiler
Config - Global tiler options.
Enums§
- Downscaling
Method - Downscaling method used for lower-resolution pyramid levels.
- Interpolation
Mode - Interpolation mode for pixel sampling.
- Output
Format - Output image formats supported by the tiler.
- Projection
- Input projection format of the source image.
- Tiler
Error
Functions§
- generate_
cube_ faces - Generates the 6 cubemap face images from an equirectangular or cylindrical input image.
- generate_
pannellum_ config - generate_
pyramid - Breaks down each of the high-res faces into multi-resolution pyramids and tiles.
- process_
panorama - Process an
RgbImageinto Pannellum tiles and config. - save_
image - save_
to_ disk - Save generated tiles and the Pannellum config.json file to a given directory.
- tile_
panorama - Load a pano, generate the multi-resolution tiles, and write the output to a directory.
- tile_
panorama_ with_ guessed_ angles - Load a pano, auto-detect its angles via EXIF and XMP metadata, generate the multi-resolution tiles, and write the output to a directory.