Skip to main content

Add your description here

Project description

spyrite

Python library to create MapLibre/Mapbox compatible sprite file.

Features

  • Few dependencies (only Pillow)
  • Input: Image files of icons (no SVG support)
    • Parameters:
      • max_width: Maximum width of the sprite image, default is 1024
      • icon_height: Height of each icon, default is 32
      • padding: Gap between icons, default is 2
  • Output: MapLibre/Mapbox compatible sprite files (sprite.png and sprite.json)

Sprite Specification

  • Height of each icon is uniform (icon_height)
  • Width of each icon is proportional to the original aspect ratio
  • Total width of the sprite image does not exceed max_width in almost all cases
    • If an icon is too wide to fit in the remaining space of the current row, it is moved to the next row
    • If an icon with fixed height of icon_height is wider than max_width, the icon won't be resized and set to a row as is. Then, width of the sprite image may exceed max_width.

CLI Usage

uv sync
uv run python -m spyrite --help
usage: __main__.py [-h] [--output-dir OUTPUT_DIR] [--padding PADDING] [--icon-height ICON_HEIGHT]
                   [--max-width MAX_WIDTH]
                   icons_dir

Generate a MapLibre/Mapbox compatible sprite sheet from PNG icons.

positional arguments:
  icons_dir             Directory that contains source icons

options:
  -h, --help            show this help message and exit
  --output-dir OUTPUT_DIR
                        Directory to write output files to (default: current directory)
  --padding PADDING     XY gap (in px) inserted between icons (default: 2)
  --icon-height ICON_HEIGHT
                        Height (in px) each icon is resized to (default: 32)
  --max-width MAX_WIDTH
                        Maximum width (in px) of the generated sprite sheet (default: 1024)
uv run python -m spyrite icons_dir
# This will generate sprite.png and sprite.json in the current directory

uv run python -m spyrite icons_dir --output-dir output_dir --max-width 2048 --icon-height 128
# This will generate sprite.png and sprite.json in output_dir with specified parameters

Example

# convert maki-icons https://github.com/mapbox/maki
uv run python -m spyrite sample/maki-icons --output-dir sample

sample/sprite.png sample/sprite.json

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spyrite-0.1.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spyrite-0.1.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file spyrite-0.1.1.tar.gz.

File metadata

  • Download URL: spyrite-0.1.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for spyrite-0.1.1.tar.gz
Algorithm Hash digest
SHA256 573e5bd67452cda93be1734d12fd321583b1e4fbadb2fdf7b071678676a74903
MD5 52be3a2082cfb6bad01a899dab2bd4db
BLAKE2b-256 9aca8758ac935e74ce6d61e5cb7be31d4856e30f8d3c7941a36cb31987e7851f

See more details on using hashes here.

File details

Details for the file spyrite-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: spyrite-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for spyrite-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a89fd924e37b20f5b22b0fdb6c76d152937c34af127097532bf3b1840d8f6bed
MD5 ab5792f0df5de1c8272bf941688b0f7e
BLAKE2b-256 09e855bb920fe47ad04742bf9d761e5ebd7ca19caf6b41c07ad3cb852deae0ed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page