しずかなインターネット

日記やエッセイにちょうどいい
文章書き散らしサービス

ログイン

ISO/IEC 15948 PNG Alpha Compositing & Paeth Filters

toppng
·
公開:2026/11/2

Portable Network Graphics (ISO/IEC 15948) represents the culmination of deterministic lossless raster engineering. Originally designed in 1995 to provide an unencumbered, patent-free successor to GIF with full 32-bit truecolor and continuous alpha transparency, PNG separates image compression into two mathematically distinct stages: spatial decorrelation via per-scanline predictor filters, followed by LZ77 and canonical Huffman entropy coding via DEFLATE (RFC 1951).

When curating and optimizing transparent 32-bit RGBA graphic assets for visual repositories like [TopPNG](https://toppng.com/), the interplay between Porter-Duff alpha compositing algebra and scanline residual entropy reveals why subtle pixel-level hygiene makes such a dramatic difference in both visual fidelity and file size.

## 1. The Algebra of Porter-Duff SRC_OVER and Straight Alpha Storage

In digital compositing, Thomas Porter and Tom Duff (1984) formalized the alpha channel as a fractional coverage mask alpha in [0, 1]. When a foreground element with color C_fg and opacity alpha_fg is composited over a background C_bg, the blended output color C_out is governed by the linear interpolation:

- C_out = C_fg * alpha_fg + C_bg * (1 - alpha_fg)

ISO/IEC 15948 mandates that PNG streams store unassociated (straight) alpha, meaning the RGB channels inside the file record the pure, unattenuated object color C_fg rather than the pre-multiplied product C_fg * alpha_fg. Storing straight alpha preserves full 8-bit or 16-bit chrominance precision across delicate semi-transparent transitions such as glass reflections, soft drop shadows, and anti-aliased vector silhouettes.

## 2. Invisible Chrominance Entropy in Zero-Alpha Regions

A fascinating paradox arises wherever opacity drops strictly to zero (Alpha = 0). Because C_fg is multiplied by 0 during compositing, the RGB values stored inside a fully transparent pixel have zero visual effect on the rendered image. Yet to a lossless PNG encoder, those three RGB bytes are still literal data that must be predicted and compressed.

When graphic editing software masks out a photographic background by setting Alpha = 0 while leaving the original background RGB pixels untouched, the transparent region remains filled with invisible high-frequency color changes. As the Alan W. Paeth scanline predictor steps across those transparent pixels, it encounters non-zero differences and emits noisy residual bytes that bloat the DEFLATE bitstream.

By sanitizing fully transparent pixels (converting RGB to 0, 0, 0 strictly where Alpha = 0 while preserving every semi-transparent boundary pixel where 1 <= Alpha <= 254), the scanline predictor immediately locks onto long, unbroken runs of zero residuals, reducing lossless file size by 20% to 40% without altering a single visible pixel.