Metadata-Version: 2.4
Name: pixel-snapper
Version: 0.1.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Programming Language :: Rust
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
License-File: LICENSE
Summary: Snap pixels to a perfect grid - designed to fix messy pixel art generated by AI. Based on original work: https://github.com/Hugo-Dz/spritefusion-pixel-snapper/tree/main
Keywords: pixel-art,image-processing,grid,snap,quantize
License: MIT
Requires-Python: >=3.8
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://github.com/NoRaincheck/pixel-snapper
Project-URL: Repository, https://github.com/NoRaincheck/pixel-snapper

# Sprite Fusion Pixel Snapper - Python Binding

A Python binding for
[Pixel Snapper](https://github.com/Hugo-Dz/spritefusion-pixel-snapper) by
[Hugo Duprez](https://www.hugoduprez.com/). Snap pixels to a perfect grid -
designed to fix messy and inconsistent pixel art generated by AI.

## Example

| Input | Output |
| ----- | ------ |
| <img src="input.png" width="250" alt="Input"> | <img src="output.png" width="250" alt="Output"> |

## Installation

```bash
pip install pixel-snapper
```

Or build from source with [maturin](https://github.com/PyO3/maturin):

```bash
pip install maturin
maturin develop --features python
```

## Usage

### Library

```python
from pixel_snapper import PixelSnapperConfig, process_image, process_file_cli

# Process image bytes
config = PixelSnapperConfig(k_colors=16, pixel_size_override=8)
output_bytes = process_image(input_bytes, config)

# Process file directly
process_file_cli("input.png", "output.png", config)
```

### CLI

```bash
pixel-snapper input.png output.png
pixel-snapper input.png output.png 16
pixel-snapper input.png output.png --pixel-size 8
pixel-snapper sprites/batch_inputs sprites/batch_outputs 16
```

### Batch processing with progress

```python
from pixel_snapper import PixelSnapperConfig, process_batch

def on_event(event):
    print(f"[{event['type']}] {event}")

config = PixelSnapperConfig(k_colors=16)
process_batch("input_dir", "output_dir", config, on_event)
```

## Acknowledgments

This is a Python binding fork of
[spritefusion-pixel-snapper](https://github.com/Hugo-Dz/spritefusion-pixel-snapper)
by [Hugo Duprez](https://www.hugoduprez.com/). All credit for the original Rust
implementation goes to the original authors.

## License

MIT License - See [LICENSE](LICENSE) for details.

