Metadata-Version: 2.1
Name: png-alpha-benchmark-toolkit
Version: 1.0.2
Summary: Lossless ISO/IEC 15948 PNG Alpha-Channel Analysis, Scanline Filter Optimization & Cutout Matting Benchmark Suite.
Home-page: https://toppng.com/
Author: TopPNG
Author-email: toppng.com@gmail.com
License: MIT
Project-URL: Homepage, https://toppng.com/
Project-URL: Source, https://github.com/toppng-source/png-alpha-benchmark-toolkit
Keywords: png,alpha-channel,compression,iso-15948,paeth-filter,image-processing
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Multimedia :: Graphics
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# png-alpha-benchmark-toolkit

Lossless **ISO/IEC 15948** PNG Alpha-Channel Analysis, Scanline Filter Optimization (`Sub`, `Up`, `Average`, `Paeth`), and Zero-Alpha RGB Entropy Elimination Benchmark Suite maintained by [TopPNG](https://toppng.com/).

## Overview

When encoding 32-bit RGBA raster graphics with transparent cutouts, standard unoptimized encoders retain arbitrary non-zero `(R, G, B)` chrominance bytes inside fully transparent pixels (`Alpha = 0`). Those hidden chrominance transitions degrade spatial predictor accuracy across scanlines (`Sub`, `Up`, `Average`, `Paeth`) and inflate LZ77/DEFLATE stream entropy.

`png-alpha-benchmark-toolkit` provides a deterministic reference implementation for:
1. **Zero-Alpha RGB Bleed Elimination:** Zeroing `(R, G, B)` channels wherever `A == 0` while strictly preserving partial anti-aliased edge pixels (`1 <= A <= 254`).
2. **ISO/IEC 15948 Section 9.2 Paeth Predictor Evaluation:** Computing exact per-scanline predictor residuals and selecting minimum-entropy filter modes.
3. **Alpha-Channel Trim Bounding-Box Calculation:** Locating minimal non-zero alpha bounding boxes `(min_x, min_y, max_x, max_y)` in `O(W * H)` time.

## Installation

```bash
pip install png-alpha-benchmark-toolkit
```

## Quick Start

```python
from png_alpha_benchmark_toolkit import (
    paeth_predictor,
    zero_alpha_rgb_bleed,
    alpha_bounding_box,
)

# 1. Compute ISO/IEC 15948 Section 9.2 Paeth predictor
pred = paeth_predictor(120, 118, 115)

# 2. Zero RGB channels on fully transparent pixels (A == 0)
rgba = bytearray([255, 128, 64, 0, 40, 80, 120, 255])
saved_bytes = zero_alpha_rgb_bleed(rgba)

# 3. Compute tight non-zero alpha bounding box
bbox = alpha_bounding_box(bytes(rgba), width=2, height=1)
```

## License

MIT License — Copyright (c) 2026 TopPNG.

