Skip to main content

Simple texture atlas packer

Project description

image Build

A simple, runtime-dependency-free texture atlas packer.

Basic usage:

from patlas import AtlasPacker, load
from glob import glob

ap = AtlasPacker(side=2048, pad=2)
ap.pack(glob('images/*.png')) # list of images
ap.pack(['images/image.jpg']) # can call multiple times (packing quality may suffer)

ap.atlas # memoryview of RGBA texture
ap.metadata # dictionary of image locations

ap.save('atlas') # serialize as custom .patlas file

atlas, metadata = load('atlas.patlas')

See demo.py for example usage with ModernGL.

Features/limitations:

  • Uses stb_image and stb_rect_pack from stb
    • Can import any image format stb_image can (see here)
  • Only square RGBA textures (currently)
  • Optional OpenMP support (disabled by default to reduce wheel size) can substantially reduce runtime. To enable, build from source with OMP=1 set in the environment, e.g. OMP=1 pip install patlas --no-binary patlas
    • On Windows, should "just work"?
    • MacOS may need extra packages, e.g. libomp from brew
    • Linux may need extra packages, e.g. libomp-dev on Ubuntu
  • Save to a custom .patlas file
    • Uses qoi image format + zlib for fast and small encoding/decoding
    • See the save method of AtlasPacker for gory details
  • Includes a command-line utility (see patlas --help for details)
  • Requires Cython at build time (but source distribution should have pre-generated .c files)

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

patlas-0.0.3.zip (230.4 kB view hashes)

Uploaded Source

Built Distributions

patlas-0.0.3-cp310-cp310-win_amd64.whl (128.1 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

patlas-0.0.3-cp310-cp310-win32.whl (109.4 kB view hashes)

Uploaded CPython 3.10 Windows x86

patlas-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (837.5 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

patlas-0.0.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (815.7 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

patlas-0.0.3-cp310-cp310-macosx_10_9_x86_64.whl (185.1 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

patlas-0.0.3-cp39-cp39-win_amd64.whl (128.7 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

patlas-0.0.3-cp39-cp39-win32.whl (110.0 kB view hashes)

Uploaded CPython 3.9 Windows x86

patlas-0.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (839.9 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

patlas-0.0.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (818.6 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

patlas-0.0.3-cp39-cp39-macosx_10_9_x86_64.whl (185.7 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

patlas-0.0.3-cp38-cp38-win_amd64.whl (128.7 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

patlas-0.0.3-cp38-cp38-win32.whl (109.9 kB view hashes)

Uploaded CPython 3.8 Windows x86

patlas-0.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (849.9 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

patlas-0.0.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (827.8 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

patlas-0.0.3-cp38-cp38-macosx_10_9_x86_64.whl (185.1 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

patlas-0.0.3-cp37-cp37m-win_amd64.whl (128.0 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

patlas-0.0.3-cp37-cp37m-win32.whl (108.9 kB view hashes)

Uploaded CPython 3.7m Windows x86

patlas-0.0.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (805.0 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

patlas-0.0.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (777.8 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

patlas-0.0.3-cp37-cp37m-macosx_10_9_x86_64.whl (184.3 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

patlas-0.0.3-cp36-cp36m-win_amd64.whl (146.0 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

patlas-0.0.3-cp36-cp36m-win32.whl (120.6 kB view hashes)

Uploaded CPython 3.6m Windows x86

patlas-0.0.3-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (792.0 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

patlas-0.0.3-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (764.7 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ ARM64

patlas-0.0.3-cp36-cp36m-macosx_10_9_x86_64.whl (182.4 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

Supported by

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