spritore
spritore generates the PNG sprite sheet and JSON index used by MapLibre
styles. Install its command for directory-based asset builds, or use its Rust
API when your application works with SVG strings and generated bytes directly.
The CLI fits static site builds, map-style repositories, and CI jobs. The Rust API fits asset services, desktop tools, and other applications that need sprite generation as part of a larger workflow.
CLI
The command reads lowercase .svg files and generates these files by default:
public/sprites/
├── sprite.png
├── sprite.json
├── sprite@2x.png
└── sprite@2x.json
The complete command is:
spritore build <svg-dir> -o <out-dir> [--name sprite] [--ratio 1,2] [--fast] [--skip-invalid]
--name <name>changes the output basename.--ratio <ratios>accepts comma-separated integers from 1 to 255.--fastprioritizes generation speed over PNG file size.--skip-invalidreports SVG parse errors and continues with valid icons.
Without --skip-invalid, an invalid SVG stops the command before output files
are written. Icon IDs come from filename stems; characters outside
a-zA-Z0-9_- become -, and collisions after conversion are errors.
Rust API
Disable default features when an application needs the library API without the command-line executable:
Or add it to Cargo.toml:
[]
= { = "0.2.0", = false }
use ;
Use render_icon by itself when you need RGBA pixels for MapLibre's
map.addImage. Use BuildOptions { fast: true } for interactive previews; the
default mode prioritizes smaller final assets.
Features
cli(default) builds thespritoreexecutable.--no-default-featuresis intended for applications that only use the Rust library API.
SVG limitations
- External resources such as linked images and web fonts are not loaded.
- SVG
<text>is not supported because fonts are not bundled. Text elements may parse successfully but are not rendered.
License
Licensed under either Apache-2.0 or MIT, at your option.