Skip to main content

aseprite

CI License

A Python library for reading and writing Aseprite .ase / .aseprite files, based on the file format specification.

This project is unofficial and is not affiliated with Igara Studio. It works directly with files and does not require the Aseprite application.

  • RGBA, grayscale, and indexed color
  • Layers, groups, tilemaps, tilesets, and linked cels
  • Animation tags, palettes, and slices with nine-patch centers and pivots
  • Color profiles, external file references, and typed user data
  • Frame rendering with Normal blending and optional PNG export

Installation

Requires Python 3.12 or later.

uv add aseprite

Or with pip:

pip install aseprite

Include the Pillow extra for image export:

uv add "aseprite[image]"

Open and export a sprite

from aseprite import Sprite

sprite = Sprite.open("hero.aseprite")
print(sprite.size, sprite.color_mode)
print(len(sprite.frames), "frames")
print([layer.name for layer in sprite.layers])

sprite.image(frame=0).save("hero.png")

image() returns a Pillow image. Use flatten() for raw RGBA bytes. Rendering supports Normal blending; use Aseprite to export other blend modes.

Sprite.from_bytes(data) reads from memory. open() and save() also accept binary file objects:

from io import BytesIO

buf = BytesIO()
sprite.save(buf)
buf.seek(0)
copy = Sprite.open(buf)

Create and animate

A new sprite starts with one layer and one frame.

from aseprite import Sprite

sprite = Sprite(32, 32)
layer = sprite.layers[0]
pixels = sprite.blank_pixels()
pixels[0, 0] = (255, 0, 0, 255)
pixels[1, 0] = (0, 255, 0)
sprite.frames[0][layer] = pixels

walk = sprite.add_frame(duration_ms=80)
walk.set_linked_cel(layer, source_frame=0)
sprite.add_tag("walk", 0, 1)
sprite.save("hero.aseprite")

Nest layers by passing a group as the parent:

from aseprite import LayerType

group = sprite.add_layer("body", kind=LayerType.GROUP)
sprite.add_layer("outline", parent=group)

for child in sprite.layers.children(group):
    print(child.name)

Inspect layers and metadata

Layers, tags, slices, and tilesets support lookup by index or name. Use get() for an optional lookup.

idle = sprite.tags.get("idle")
if idle is not None:
    print(idle.from_frame, idle.to_frame, idle.direction)

if "outline" in sprite.layers:
    outline = sprite.layers["outline"]
    print(outline.visible, outline.opacity)

box = sprite.slices.get("box")
if box is not None:
    print(box.keys[0])

frame.cel(layer) returns the cel, or None if that layer has no cel. RGBA and grayscale pixels are Color values; indexed pixels are integers.

cel = sprite.frames[0].cel(sprite.layers[0])
if cel is not None and cel.pixels is not None:
    print(cel.x, cel.y, cel.pixels[0, 0])

Indexed color

Populate the palette, then draw with palette indices:

from aseprite import Color, ColorMode, Palette, Sprite

sprite = Sprite(16, 16, ColorMode.INDEXED)
sprite.palette = Palette([Color(0, 0, 0, 0), Color(255, 80, 40)])
sprite.transparent_index = 0

pixels = sprite.blank_pixels()
pixels[2, 3] = 1
sprite.frames[0][sprite.layers[0]] = pixels

To animate colors, assign a new Palette to frame.palette. Use sprite.palette_at(frame) to get the palette effective at a frame.

Slices and user data

Add named bounds for hitboxes, layout, or export regions:

from aseprite import SliceKey

sprite.add_slice("hitbox", [SliceKey(frame=0, x=2, y=2, width=12, height=12)])

Attach text, colors, and typed properties to document objects:

from aseprite import PropertiesMap, PropertyType, UserData, UserProperty

sprite.layers[0].user_data = UserData(
    text="npc",
    properties=[PropertiesMap(0, [UserProperty("hp", PropertyType.INT32, 10)])],
)

Detailed behavior, mutation rules, and allocation limits are documented on the corresponding APIs. For example, use help(Sprite.flatten), help(Sprite.from_bytes), or help(type(sprite.layers)).

Examples

These scripts generate their own artwork and use the local package:

Run an example with uv run, optionally passing an output path:

uv run examples/indexed_animation.py flame.aseprite

Command line

python -m aseprite info hero.aseprite
python -m aseprite export hero.aseprite hero.png --frame 0

export requires the aseprite[image] extra.

Development

uv sync --all-extras --dev
uv run ruff format
uv run ruff check
uv run ty check
uv run pytest

In VS Code, install the recommended workspace extensions and select the .venv interpreter. Workspace settings use Ruff for linting and formatting, ty for type checking, and pytest for test discovery, with rules kept in pyproject.toml. Python files are formatted and safe Ruff fixes are applied when you save.

The tests use Hypothesis for generated documents and include regression cases for reading, writing, rendering, and editing. Set HYPOTHESIS_PROFILE=long for an extended search.

Editor comparisons run when Aseprite is available. On macOS the suite looks in /Applications/Aseprite.app; set ASEPRITE_PATH to use another binary. The rest of the suite runs without the editor.

On macOS, editor tests prepare a temporary CLI copy once per test session to avoid Dock animations. To troubleshoot a launch against the installed app directly, use uv run pytest --aseprite-launch=direct.

License

aseprite is available under the Apache 2.0 license. Aseprite is separate software under its own license.

Contact

Mattt (@mattt)

Metadata

Release files for aseprite 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aseprite 0.1.0
File Size Uploaded Provenance Actions
aseprite-0.1.0.tar.gz 35.9 kB With provenance Details for aseprite-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aseprite 0.1.0
File Interpreter ABI Platform Actions
aseprite-0.1.0-py3-none-any.whl Python 3 none any Details for aseprite-0.1.0-py3-none-any.whl

Total release size: 76.6 kB

Release files / aseprite-0.1.0.tar.gz

Download URL aseprite-0.1.0.tar.gz
Size 35.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c8e13dd22d21c34f0394033354f632bade1a46673959b6f8c00ea453a9718cf9
BLAKE2b-256 checksum
How to use checksums
c06e4f67598438026468acb125934bf45b91aa862917628ceb16f4eb0ce80eb9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / aseprite-0.1.0-py3-none-any.whl

Download URL aseprite-0.1.0-py3-none-any.whl
Size 40.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d554a480e76e60beec11e2ac91dc02cf5fa52bb7b741d8918ec4279cb09d542f
BLAKE2b-256 checksum
How to use checksums
6b0b72ef8ee3c94795acfc979afe0b0c36109f267371dc177a850ba6806ed825
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Security for aseprite 0.1.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for aseprite-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page