Fundamentals

Transparency in images

Alpha channels, binary transparency and what gets lost in conversion

How alpha channels, palette transparency and GIF-style binary transparency differ, why edges grow halos, why a transparent PNG turns into a white box as a JPG, and how to check what a file really contains before you convert it.

On this page

Transparency is the part of an image you cannot see, which is why it causes so many surprises. A logo that looked perfect in the design tool arrives on a dark page with a pale fringe; a product cut-out becomes a white rectangle after someone “just saved it as a JPG”; a deliberately transparent home-screen icon shows up on a black square. All of these come from a handful of facts about how formats store opacity, and the fixes follow from them.

Three ways an image can be transparent

Formats describe transparency in three ways, and the differences decide what can go wrong.

Method Formats Levels of opacity Edge quality
Full alpha channel PNG (greyscale+alpha, truecolour+alpha), WebP, AVIF, TIFF 256 levels at 8 bits per channel, 65,536 at 16 bits Smooth, anti-aliased edges and soft shadows
Palette transparency PNG with an indexed palette and a tRNS chunk Up to 256 levels, one per palette entry Smooth if the quantiser kept enough semi-transparent entries
Colour-key transparency PNG greyscale or truecolour with a tRNS chunk One: a single colour value is fully transparent Hard, jagged edges
Binary transparency GIF One: a single palette index per frame is transparent Hard, jagged edges
Three versions of a round badge with a soft shadow: with alpha on a checkerboard the edge and shadow blend smoothly; saved as JPEG the checkerboard is replaced by a white box; with one-bit transparency the shadow disappears and the edge is stepped.PNG / WebP with alphalogo256 levels, smooth edge and shadowSaved as JPGlogoNo alpha: flattened onto whiteGIF-style 1-bitlogoEach edge pixel is on or off
The same badge three ways: a full alpha channel blends the edge and shadow into any background; saving as JPG flattens everything onto white because JPEG has no alpha; one-bit (GIF-style) transparency keeps the background but turns every edge pixel fully on or off, so edges step and the soft shadow disappears.

A full alpha channel

An alpha channel is a fourth value stored beside red, green and blue for every pixel (or a second value beside grey). At 8 bits it runs from 0, fully transparent, to 255, fully opaque, and everything between is partially see-through. This is what makes anti-aliased edges, drop shadows and glass effects possible: pixels along a curved edge are 30 % or 70 % opaque, so the edge looks smooth against whatever lies behind it. PNG stores alpha at 8 or 16 bits; WebP and AVIF at 8 bits. JPEG has no alpha channel at all.

Palette and colour-key transparency

An indexed PNG holds a palette of up to 256 colours and stores one palette index per pixel. The optional tRNS chunk adds an alpha value to each palette entry, so a palette image can still have soft edges as long as the quantiser reserved entries for semi-transparent colours. This is how a palette-based PNG compressor shrinks a 32-bit logo dramatically without losing its edges, as the compression guide explains.

The same chunk means something different in a greyscale or truecolour PNG without an alpha channel: it names one exact colour value to treat as fully transparent. This “colour key” approach is cheap, but every pixel is either entirely visible or entirely hidden, and any pixel that happens to share the key colour disappears too.

Binary transparency in GIF

GIF offers only the colour-key approach: the Graphic Control Extension for each frame can flag one palette index as transparent, so edges cannot be anti-aliased against an unknown background. Exporters compensate by blending edge pixels toward an assumed background colour, which looks fine on that colour and shows a fringe on any other.

Straight versus premultiplied alpha, and where halos come from

There are two ways to store a semi-transparent pixel. With straight (non-premultiplied) alpha the colour values describe the pixel's own colour regardless of opacity: a 50 % opaque red pixel is stored as full red plus an alpha of 128. With premultiplied alpha the colour values have already been multiplied by the opacity, so the same pixel is stored as half-intensity red plus 128. PNG stores straight alpha; graphics hardware and compositors usually work premultiplied because blending is simpler there.

The distinction matters whenever pixels are mixed, which happens every time an image is resized, rotated, blurred or sharpened. Interpolating straight alpha treats the colour of fully transparent pixels as real data; those pixels are often stored as black, so a resized cut-out develops a dark fringe where black has bled into the edge. A careful pipeline premultiplies before resampling and un-premultiplies afterwards, which is why the same resize looks clean in one tool and haloed in another.

The light halo is the opposite problem and comes from the content rather than the maths. A subject cut out from a white background keeps edge pixels that were blended with white when the photograph was anti-aliased; placed on a dark surface, every edge pixel carries a trace of white. Image editors call the fix “defringe”, “remove white matte” or “decontaminate colours”; all of them estimate and remove the background colour that leaked into the edge.

Check for both at 200 % or more against a dark and a light background before publishing; at 100 % on a light page the halo is easy to miss.

Why a transparent PNG becomes a white box as a JPG

JPEG stores three colour channels and nothing else. When a PNG with transparent areas is converted, every transparent pixel has to become some opaque colour, and the converter decides which. Most choose white; a lazy implementation that simply drops the alpha channel exposes whatever colour was stored underneath, often black. The result is the familiar logo-in-a-rectangle, and no encoder setting can prevent it, because the format has nowhere to put the information.

The decision is not whether to flatten – that is unavoidable – but what to flatten onto. The PNG to JPG converter on this site makes you pick the background colour and warns before transparency is discarded. If the transparency must survive, JPEG is the wrong target; convert to WebP or keep the PNG, as the format guide explains.

Choosing the background colour

Match the surface the image will sit on. For a document, an email or a light web page that usually means white; for a dark theme it means the exact dark colour of the page, not “black” from a palette, because a slightly wrong dark grey is as visible as white. For product photos placed by a marketplace, use the background the marketplace specifies.

When the destination is unknown, a neutral light colour is the least bad choice, but semi-transparent edge pixels will be blended toward it, so the flattened image looks correct only on that colour and shows a faint outline on anything else. If the image must work on several backgrounds, keep a format with alpha.

Matting and de-fringing

Matting is the deliberate version of the blend described above. When an exporter writes a format that cannot hold soft edges – GIF, colour-key PNG, JPEG – it blends each partially transparent pixel with a chosen matte colour and makes it opaque. A good export dialog exposes that colour; a poor one silently uses white. The edge then looks smooth on the matte colour and fringed on others.

De-fringing goes the other way: given edges that already carry a background colour, it estimates how much of that colour each edge pixel contains and removes it, restoring something closer to straight alpha. It is a repair, not a restoration; detail blended away cannot be fully recovered, which is one more reason to keep the layered or 32-bit original.

Checking whether a PNG actually uses its alpha channel

A PNG can declare an alpha channel and never use it. Design tools often export everything as truecolour with alpha even when every pixel is opaque, which costs a byte per pixel and makes people hesitate to convert to JPEG because “it might be transparent”. The reverse happens too: a file with no alpha channel can be transparent through a tRNS chunk, and an image can look transparent in a thumbnail because a grey-and-white checkerboard was baked into its pixels.

The PNG transparency checker settles this by reading the header, then decoding the image and counting pixels. It reports the colour type, how many pixels are fully and partially transparent, and the bounding box of the visible content, with a preview over a real checkerboard. A verdict of “no transparency” on an RGBA file means you can convert it to RGB or JPEG without losing anything; “binary transparency” means a colour-key or one-bit mask with hard edges; “soft alpha” means the image needs a proper alpha channel. The bounding box is useful too: a logo with 40 % empty margin wastes bytes, and the cropper can trim it.

Transparency in WebP, AVIF and SVG

WebP supports alpha in both modes. Lossless WebP stores alpha exactly, like PNG. Lossy WebP compresses the colour with the VP8-based codec and stores the alpha plane separately, losslessly by default, with an optional lossy setting in the reference encoder; soft edges survive, which is what makes WebP the usual recommendation for transparent photos. Be aware that encoders, PNG optimisers included, may discard the colour stored under fully transparent pixels to improve compression. That is invisible on screen but matters if you intend to edit the alpha later, so keep the original.

AVIF carries an alpha channel as an auxiliary image and handles soft edges well. Converting WebP or AVIF to PNG keeps the alpha intact; the WebP to PNG converter exists largely for applications that cannot open WebP but need the transparency preserved.

SVG has no background unless you draw one, so any area not covered by a shape is transparent. Opacity is controlled per element with opacity, fill-opacity and stroke-opacity, or with RGBA colours. When an SVG is rasterised those areas become ordinary alpha; the SVG to PNG tool lets you keep them transparent or render onto a solid colour. If an exported SVG shows a white background you did not expect, look for a full-size <rect> added as an artboard.

Icons and favicons

Browser tab icons – .ico, PNG or SVG – display transparency correctly, and a transparent background is normal for them. Home-screen and launcher icons are different.

iOS does not display transparency in home-screen icons; transparent regions are filled in, so a logo with a transparent background typically appears on a black square. Give the Apple touch icon an opaque background of your choosing. Android's maskable icons go further: the launcher cuts the icon into a circle, squircle or other shape, so the image must fill its whole canvas with an opaque background and keep the important content inside the safe zone, a central circle whose diameter is 80 % of the icon's width according to the Web Application Manifest specification.

The favicon generator gives the Apple touch icon an opaque background automatically if you have not chosen one, and lets you add padding to keep a logo inside the safe zone; the favicon guide covers the sizes.

A short checklist

  1. Run the transparency checker before converting: find out whether the file has no transparency, binary transparency or soft alpha.
  2. Keep soft alpha in PNG, WebP or AVIF; never route it through JPEG or GIF.
  3. When flattening is unavoidable, choose the background colour to match the destination surface.
  4. Inspect edges at 200 % against both a light and a dark background; de-fringe if you see a halo.
  5. Give Apple touch icons and maskable Android icons an opaque background; leave tab icons transparent.
  6. Keep the layered or 32-bit original. Everything above is easier to redo from it than to repair.

Try it: PNG Transparency Checker to see what kind of transparency a file uses, then PNG to JPG with a background colour you choose if it must be flattened.

Sources and further reading

About the author

HelpMeJPG editorial teamEditorial team

The people who build and maintain the HelpMeJPG tools. Guides are written from the tools' own behaviour and the standards they implement, and are revised whenever a tool changes.