Turn AI-generated pixel-style images into true, grid-aligned pixel art sprites.
pip install pxl-cleanup Copy PIP instructions
Turn AI-generated "pixel art" into real pixel art sprites.
Image models like FLUX produce images that look like pixel art from a distance, but the "pixels" are uneven blocks with gradients inside them, sitting on a background, with tens of thousands of colors. pxl-cleanup turns that into a small, grid-aligned, transparent sprite with a limited palette, ready to animate or drop into a game.
# run once without installing uvx pxl-cleanup trex.jpg # or install the command uv tool install pxl-cleanup # or: pipx install pxl-cleanup / pip install pxl-cleanup Usage # one sprite: writes out/trex/1_nobg.png ... 4_final.png pxl-cleanup trex.jpg # a whole roster at once, each in its own subfolder of sprites/ pxl-cleanup beasts/*.jpg --out sprites # Sega Genesis-style palette (15 colors + transparency) pxl-cleanup trex.jpg --colors 15 Every stage is saved as its own PNG, so when a result looks wrong you can see which stage caused it.
from PIL import Image from pxl_cleanup import remove_background, recover_grid, reduce_palette, place_on_canvas sprite = place_on_canvas(reduce_palette(recover_grid(remove_background(Image.open("trex.jpg"))))) sprite.save("trex.png") Getting good input The background stage assumes an outlined character on a plain light background. Add this to your image prompt so every generation fits:
plain white background, no ground, no shadow, thick dark outline, full body, side view
examples/trex/ has the source image and the output of every stage, including a 15-color version.
git clone https://github.com/alvincrespo/pxl-cleanup.git cd pxl-cleanup python3 -m venv .venv && source .venv/bin/activate pip install -e ".[dev]" pytest Releasing Publishing to PyPI is automated. Bump version in pyproject.toml and __version__ in src/pxl_cleanup/__init__.py, push, then create a GitHub release with a matching tag (for example v0.1.1). The publish workflow builds the package and uploads it to PyPI using trusted publishing, so no API token is stored anywhere.
All 2 files in this release have provenance metadata.
pixel-art sprites gamedev ai-art image-processing
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
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 verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.
All 2 files in this release have been uploaded with provenance metadata.
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.




