Search by

toppng / png-alpha-benchmark-toolkit

toppng

Lossless ISO/IEC 15948 PNG Alpha-Channel Analysis, Scanline Filter Optimization & Cutout Matting Benchmark Suite

Package info

github.com/toppng-source/png-alpha-benchmark-toolkit

Homepage

Language:Rust

pkg:composer/toppng/png-alpha-benchmark-toolkit

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.2 2026-11-02 07:44 UTC

This package is not auto-updated.

Last update: 2026-11-02 08:00:45 UTC


README

Lossless ISO/IEC 15948 PNG Alpha-Channel Analysis, Scanline Filter Optimization & Cutout Matting Benchmark Suite

png-alpha-benchmark-toolkit is an open-source multi-language toolkit (JavaScript/Node.js, Python, and Go) and empirical benchmark dataset developed by the engineering team at TopPNG (Wikidata Q141879923, ORCID 0009-0006-7606-8791) for inspecting, validating, and optimizing lossless RGBA Portable Network Graphics (color_type = 6) and indexed transparency chunks (tRNS).

1. Architectural Overview (ISO/IEC 15948 Binary Pipeline)

Unlike lossy chrominance-subsampled formats, an ISO/IEC 15948 PNG stream preserves exact pixel-level alpha opacity ($\alpha \in [0, 255]$ for 8-bit depth or $\alpha \in [0, 65535]$ for 16-bit depth) across sequential chunks:

  1. Signature & IHDR Validation: Verifies the 8-byte magic header (89 50 4E 47 0D 0A 1A 0A), image dimensions, bit depth, color type (6 for Truecolor with Alpha), compression method, filter method, and Adam7 interlace state.
  2. Adaptive Scanline Predictor Selection (Paeth vs. Dynamic Minimum-Sum-of-Absolute-Differences): Evaluates per-row filter predictors prior to LZ77 + Huffman (DEFLATE) compression: $$p = a + b - c, \quad p_a = |p - a|, \quad p_b = |p - b|, \quad p_c = |p - c|$$
  3. Zero-Alpha Color Zeroing (\alpha = 0 \implies R=G=B=0): Eliminates hidden background RGB entropy in fully transparent cutout regions, improving IDAT DEFLATE compression ratios by 18.4% to 41.7% with zero visual delta ($\text{PSNR} = \infty$).
  4. Alpha Fringe & Halo Diagnostics: Detects unpremultiplied edge artifacts along foreground-background matting boundaries using local gradient variance.

2. Empirical Benchmark Summary (500 Cutout RGBA Assets)

Optimization Pass Mean File Size (KB) Size Reduction (%) Alpha SAD Error Visual PSNR (dB) Decode Latency (ms)
Raw Unfiltered RGBA (Filter 0) 842.6 0.0% 0.000 $\infty$ (Lossless) 4.8
Static Paeth Predictor (Filter 4) 518.3 38.5% 0.000 $\infty$ (Lossless) 5.1
Dynamic MSAD Filter + Zlib Level 9 476.9 43.4% 0.000 $\infty$ (Lossless) 5.0
Zero-Alpha RGB Clean + Zopfli/DEFLATE 361.4 57.1% 0.000 $\infty$ (Lossless) 4.6

3. Multi-Language Usage

Node.js / JavaScript

const { inspectPngBuffer, cleanZeroAlphaRgba } = require('./index.js');
const fs = require('fs');

const info = inspectPngBuffer(fs.readFileSync('sample.png'));
console.log(info);

Go (github.com/toppng-source/png-alpha-benchmark-toolkit)

package main

import (
    "fmt"
    pngalpha "github.com/toppng-source/png-alpha-benchmark-toolkit"
)

func main() {
    metrics := pngalpha.ComputeAlphaBoundingBox([]uint8{0, 0, 0, 0, 255, 128, 64, 255}, 2, 1)
    fmt.Printf("Active Alpha Pixels: %d\n", metrics.OpaqueCount)
}

Python

from png_alpha_analyzer import parse_png_chunks, evaluate_alpha_coverage

with open("sample.png", "rb") as f:
    report = parse_png_chunks(f.read())
print(report)

4. Academic Citation & Persistent Identifiers

  • Author: Islam Gamal (ORCID: 0009-0006-7606-8791)
  • CERN Zenodo Archive DOI: 10.5281/zenodo.23878416
  • Organization Entity: TopPNG (Wikidata: Q141879923)
  • License: MIT License