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'))
ap.pack(['images/image.jpg'])
ap.atlas
ap.metadata
ap.save('atlas')
atlas, metadata = load('atlas.patlas')
See demo.py for example usage with ModernGL.
Features/limitations:
- Uses
stb_image
, stb_rect_pack
, and stb_dxt
from stb
- Can import any image format
stb_image
can (see here)
- Only square RGBA textures (currently)
- Optional DXT5/BC3(?) compression
- 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)