Skip to content

v5.7.0: fix(images): keep transparency when view_image downscales and re-encodes

Latest

Choose a tag to compare

@github-actions github-actions released this 18 Nov 07:45
Transparent pixels are now only ever re-encoded as PNG — JPEG has no alpha
channel, so a transparent background used to be flattened onto black when
JPEG won the size comparison. An alpha channel that is fully opaque still
counts as opaque and may come back as JPEG.

Map channel counts to explicit stb resize layouts so grey+alpha images are
filtered with alpha weighting instead of bleeding transparent pixels into
the edge, reject decoded buffers outside 1–4 channels, and retry bigger
budget overflows with more halvings (16) until a PNG fits.

Add makePngPixels and tests covering transparency, grey+alpha, the budget
path and the opaque-alpha case; bump the version to 5.7.0.