Skip to main content

panorama_tiler/
lib.rs

1#![deny(clippy::unwrap_used)]
2#![allow(
3    clippy::missing_errors_doc,
4    clippy::cast_precision_loss,
5    clippy::cast_possible_truncation,
6    clippy::cast_sign_loss,
7    clippy::cast_possible_wrap
8)]
9
10//! A library to generate multi-resolution cubemap tiles and Pannellum-compatible configurations
11//! from equirectangular or cylindrical panoramas.
12//!
13//! # Overview
14//! `panorama-tiler` processes a single stitched panorama image into:
15//! 1. Six cubemap face images (`front`, `back`, `up`, `down`, `left`, `right`).
16//! 2. A multi-resolution pyramid containing cropped tile segments at configurable zoom levels.
17//! 3. A JSON configuration file (`config.json`) mapped directly to Pannellum's configuration format.
18//!
19//! # Feature Flags
20//! - **`metadata`** (Enabled by default): Enables automatic projection angle and crop detection using XMP and EXIF tags.
21//! - **`webp`** (Enabled by default): Adds support for encoding tile output in the WebP format.
22//!
23//! # Examples
24//!
25//! ### Automatic Metadata Processing
26//! If the source panorama contains valid EXIF or `GPano` XMP tags, you can process the image with
27//! automatic angle extraction:
28//!
29//! ```rust,no_run
30//! # #[cfg(feature = "metadata")]
31//! # {
32//! use panorama_tiler::{OutputConfig, OutputFormat, tile_panorama_with_guessed_angles};
33//! use std::path::Path;
34//!
35//! fn main() -> Result<(), panorama_tiler::TilerError> {
36//!     let input = Path::new("input_photosphere.jpg");
37//!     let output = Path::new("tiles_output");
38//!     
39//!     let config = OutputConfig {
40//!         format: OutputFormat::Webp,
41//!         quality: 85,
42//!         ..Default::default()
43//!     };
44//!
45//!     tile_panorama_with_guessed_angles(input, output, Some(config))?;
46//!     Ok(())
47//! }
48//! # }
49//! ```
50//!
51//! ### Manual Configuration Processing
52//! If metadata tags are absent, parameters can be passed manually:
53//!
54//! ```rust,no_run
55//! use panorama_tiler::{
56//!     TilerConfig, PanoAngles, OutputConfig, Projection, OutputFormat, tile_panorama
57//! };
58//! use std::path::Path;
59//!
60//! fn main() -> Result<(), panorama_tiler::TilerError> {
61//!     let config = TilerConfig {
62//!         angles: PanoAngles {
63//!             haov: 180.0,
64//!             vaov: 90.0,
65//!             projection: Projection::Cylindrical,
66//!             ..Default::default()
67//!         },
68//!         output: OutputConfig {
69//!             tile_size: 512,
70//!             format: OutputFormat::Jpeg,
71//!             quality: 85,
72//!             ..Default::default()
73//!         },
74//!     };
75//!
76//!     tile_panorama(
77//!         Path::new("input_pano.jpg"),
78//!         Path::new("tiles_output"),
79//!         &config,
80//!     )?;
81//!     Ok(())
82//! }
83//! ```
84
85mod config;
86mod error;
87pub mod exif;
88mod logic;
89mod orchestrator;
90
91pub use config::*;
92pub use error::TilerError;
93pub use logic::*;
94pub use orchestrator::*;