Menu

Your transparent PNG gains a white fringe in the browser: premultiplied alpha, explained
📰

Your transparent PNG gains a white fringe in the browser: premultiplied alpha, explained

DEV Community: css·neo xia·about 8 hours ago
#pI7jevCn
#devtocss#devto#dev#canvas#white
Long article (1063 words) — no AI summary yet.
Reading 0:00
15s threshold

A cutout that looks clean in the editor can pick up a pale halo the moment it lands in a browser. The halo is usually blamed on the background-removal model. Most of the time the model is fine and the pipeline is not: the pixels were matted to white somewhere between export and paint, or they were round-tripped through a canvas until the edge color fell apart.

This post is about the second failure mode, because it is the one you can reproduce in ten minutes with the tools already in the tab.

The symptom

Open a transparent PNG in an image editor on a dark canvas and the edge looks reasonable. Put the same file on a dark page and a light rim appears. Zoom in and the rim is not one clean line - it is a band of pixels whose RGB is somewhere between the subject color and white, with alpha somewhere between 0 and 1.

That band is not necessarily wrong. A soft edge is made of partially transparent pixels by definition. What makes it look wrong is the color stored in those pixels.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.