SpineAtlas
Modify atlas data and export frames or convert other atlas-like data to spine atlas
Installation
Install the latest version of SpineAtlas from PyPI:
pip install SpineAtlas
Usage
Opening and saving atlas
from SpineAtlas import ReadAtlasFile
atlas = ReadAtlasFile('1.atlas')
# The code will automatically determine the format of Atlas
atlas.version = False # Convert to Atlas 3.0 format
atlas.version = True # Convert to Atlas 4.0 format
atlas.SaveAtlas('1_v4.atlas')
Check if the atlas is missing a textures
from SpineAtlas import ReadAtlasFile
atlas = ReadAtlasFile('1.atlas')
# If the texture and atlas are in the same directory, you don't need to pass the path
miss = atlas.CheckTextures()
# If `miss` is empty, it means there is no missing textures
Modify the texture scaling of the atlas
from SpineAtlas import ReadAtlasFile
atlas = ReadAtlasFile('1.atlas')
# If the texture and atlas are in the same directory, you don't need to pass the path
atlas.ReScale()
atlas.SaveAtlas('1_scale.atlas')
# Atlas4.0
atlas = ReadAtlasFile('1.atlas')
atlas.version = False # If you want to save it as Atlas3.0
atlas.SaveAtlas4_0Scale(outPath=r'D:\out_scale')
Export atlas frames
from SpineAtlas import ReadAtlasFile
atlas = ReadAtlasFile('1.atlas')
# If the texture and atlas are in the same directory, you don't need to pass the texture path
# mode : ['Normal', 'Premul', 'NonPremul']
# --- Normal - do not process the texture
# --- Premul - convert the texture to premultiplied
# --- NonPremul - convert the texture to non-premultiplied
atlas.SaveFrames(path='1_frames', mode='Premul')
Convert other formats to Spine Atlas
from SpineAtlas import Atlas, AtlasTex, AtlasFrame
'''
{
Texture:
Texture_Name: str
Texture_Wdith: int
Texture_Height: int
Frame:
[
[
Frame_Name: str
Cut_X: int
Cut_Y: int
Cut_Wdith: int
Cut_Height: int
Original_X: int
Original_Y: int
Original_Wdith: int
Original_Height: int
Rotate: int
],
...
]
}
'''
TextureDict = {...}
frames = []
for i in TextureDict['Frame']:
frames.append(AtlasFrame(i['Frame_Name'], i['Cut_X'], i['Cut_Y'], i['Cut_Wdith'], i['Cut_Height'], i['Original_X'], i['Original_Y'], i['Original_Wdith'], i['Original_Height'], i['Rotate']))
tex = TextureDict['Texture']
texture = AtlasTex(tex['Texture_Name'], tex['Texture_Wdith'], tex['Texture_Height'], frames=frames)
atlas = Atlas([texture])
atlas.SaveAtlas('1.atlas')
Recalculate the clipping anchor point
from SpineAtlas import ReadAtlasFile, Anchor
'''
class Anchor(IntEnum):
TOP_LEFT = 1
TOP_CENTER = 2
TOP_RIGHT = 3
CENTER_LEFT = 4
CENTER = 5
CENTER_RIGHT = 6
BOTTOM_LEFT = 7
BOTTOM_CENTER = 8
BOTTOM_RIGHT = 9
'''
atlas = ReadAtlasFile('1.atlas')
# The default anchor point for Spine Atlas clipping is the top left corner
atlas.cutp = Anchor.BOTTOM_LEFT
atlas.ReOffset() # Recalculate clipping X/Y starting from the upper left corner
atlas.SaveAtlas('1_1_ReOffset.atlas')
Recalculate the Offset anchor point
from SpineAtlas import ReadAtlasFile, Anchor
'''
class Anchor(IntEnum):
TOP_LEFT = 1
TOP_CENTER = 2
TOP_RIGHT = 3
CENTER_LEFT = 4
CENTER = 5
CENTER_RIGHT = 6
BOTTOM_LEFT = 7
BOTTOM_CENTER = 8
BOTTOM_RIGHT = 9
'''
atlas = ReadAtlasFile('1.atlas')
# The default anchor point for Spine Atlas Offset is the bottom left corner
atlas.offp = Anchor.TOP_LEFT
atlas.ReOffset() # Recalculate Offset X/Y starting from the bottom left corner
atlas.SaveAtlas('1_1_ReOffset.atlas')
Convert image to premultiplied/non-premultiplied
from PIL.Image import open as imgop
from SpineAtlas import ImgPremultiplied, ImgNonPremultiplied
img = imgop('1.png')
tex = ImgPremultiplied(img)
tex.save('1_premultiplied.png')
tex = ImgNonPremultiplied(img)
tex.save('1_non-premultiplied.png')
Metadata
Release files for SpineAtlas 1.0.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spineatlas-1.0.13.tar.gz | 10.1 kB | Without provenance | Details for spineatlas-1.0.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spineatlas-1.0.13-py3-none-any.whl | Python 3 | none | any | Details for spineatlas-1.0.13-py3-none-any.whl |
Total release size: 19.2 kB
Release files / spineatlas-1.0.13.tar.gz
| Download URL | spineatlas-1.0.13.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f672ad893e7ff8c339babcde516bc3b79961545d5ae3fc8123c481cd3ccbafbd
|
|
BLAKE2b-256 checksum How to use checksums |
daf0d29e1cbc17deb5050ee5bab810943ad84894d49e5e2e87367b030729dae9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / spineatlas-1.0.13-py3-none-any.whl
| Download URL | spineatlas-1.0.13-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c5f105f7a546751d3789e0561cd7fd4b8abb4de426a3289758de4cc36366bf2a
|
|
BLAKE2b-256 checksum How to use checksums |
889cb63642b0e268e532b87f219934625692842015b7972c5bf73c50670b85db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for SpineAtlas 1.0.13
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.