Skip to main content

Crate panorama_tiler

Crate panorama_tiler 

Source
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:

  1. Six cubemap face images (front, back, up, down, left, right).
  2. A multi-resolution pyramid containing cropped tile segments at configurable zoom levels.
  3. 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§

b83
exif

Structs§

FallbackItem
A representation of a fallback cube face tile.
GeneratedTiles
Container holding the raw outputs of the multi-resolution pipeline.
MultiResConfig
OutputConfig
PannellumConfig
PanoAngles
TileItem
A representation of an individual generated tile.
TiledPanoramaOutput
TilerConfig
Global tiler options.

Enums§

DownscalingMethod
Downscaling method used for lower-resolution pyramid levels.
InterpolationMode
Interpolation mode for pixel sampling.
OutputFormat
Output image formats supported by the tiler.
Projection
Input projection format of the source image.
TilerError

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 RgbImage into 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.