Every pixel in an ordinary image is described by three numbers: how much red, green and blue it contains. That is enough to say what color the pixel is, but not whether you can see through it. The alpha channel is a fourth number per pixel that does exactly that: it stores opacity, from fully transparent to fully opaque.
When people talk about "a PNG with a transparent background", they mean an image with an alpha channel where the background pixels have an alpha of zero. This guide explains how that number works, the two ways software stores it, why edges go wrong, and how to check what a file really contains.
RGBA: four channels per pixel
MDN defines the alpha channel simply: colors are made of channels (red, green and blue), and to describe a color "through which the background can be seen to some extent", a fourth channel is added. An image with all four is called RGBA.
The value can be written in several ways, and they all mean the same thing:
| Notation | Fully transparent | Half transparent | Fully opaque |
|---|---|---|---|
| 8-bit integer (most image files) | 0 | 128 | 255 |
| 16-bit integer (16-bit PNG) | 0 | 32768 | 65535 |
| Fraction (compositing math, CSS) | 0 | 0.5 | 1 |
| Percentage (CSS) | 0% | 50% | 100% |
Hex suffix (CSS #rrggbbaa) | 00 | 80 | ff |
The PNG specification puts it precisely: an alpha value of zero is full transparency, the maximum value for the bit depth is full opacity, and intermediate values are partially transparent pixels "that can be composited against a background image".
Those intermediate values are the important part. A good cut-out is not just "subject opaque, background transparent". The pixels along the edge, especially in hair, fur, fabric, glass and motion blur, are partly transparent, and that is what makes the subject look natural on a new background instead of looking cut out with scissors.
How a transparent pixel is drawn
When an app places your image on top of something else, it blends each pixel with what is behind it. The W3C Compositing and Blending specification gives the basic formula:
result = Cs x as + Cb x ab x (1 - as)
Cs, as = color and alpha of your image (the source)
Cb, ab = color and alpha of what is behind it (the backdrop)For the common case of an opaque backdrop, that becomes a weighted average. A pixel with alpha 0.3 contributes 30% of its own color and lets 70% of the background through.
Straight vs premultiplied alpha
There are two ways to store the color of a partly transparent pixel, and mixing them up is a classic source of dark or bright fringes.
Straight alpha (also called unassociated or non-premultiplied) stores the color as if the pixel were fully opaque, and keeps the opacity separately. A half-transparent pure red pixel is stored as red 255, green 0, blue 0, alpha 128.
Premultiplied alpha (also called associated) stores the color already multiplied by the alpha. The same pixel is stored as red 128, green 0, blue 0, alpha 128. As the PNG specification puts it, such an image "is already composited against a black background".
Which one a file uses depends on the format and the software:
- PNG always uses straight alpha. The specification says so explicitly, and notes that this lets an editor change an image's transparency easily.
- Graphics pipelines, game engines and video compositing tools often work in premultiplied alpha internally, because the blending math is simpler and filtering behaves better.
Problems start when one program writes premultiplied values and another reads them as straight. The colors along the edges come out too dark, giving a thin black outline. Going the other way makes edges too bright. If you see a consistent dark rim on every cut-out from one tool, a premultiplication mismatch is the first thing to suspect.
Why cut-outs get halos
A halo is a visible rim around the subject that does not belong to it. There are four common causes, and each has its own fix.
1. The old background is baked into the edge pixels
A camera never captures a clean boundary. A strand of hair against a green hedge produces pixels that are partly hair and partly hedge. If the cut-out keeps those pixels' original colors and only makes them semi-transparent, the green stays mixed in. Placed on white, the subject now has a faint green glow.
The fix is color decontamination: estimating the true foreground color for each edge pixel and writing that instead. Photoshop calls this Decontaminate Colors in the Select and Mask workspace, and the open-source rembg library has a decontaminate option that does the same thing. It changes the edge colors, never the shape of the mask.
2. The mask is too hard
If the mask has only fully opaque and fully transparent pixels, edges look jagged, and any antialiasing in the original photo leaves a one-pixel line of background color around the subject. Soft subjects such as hair need a soft mask with real intermediate values.
3. Hidden colors in transparent pixels
A pixel with alpha zero still has red, green and blue values in a straight-alpha file. You cannot see them, but resizing or blurring an image mixes neighboring pixels, and if those hidden colors are white or black they bleed into the visible edge. Good image libraries avoid this by premultiplying before resizing and converting back afterwards.
4. The image was flattened onto a color
GIFs and palette PNGs often support only on-or-off transparency, so tools antialias the edge against a matte color, typically white, before saving. That image looks fine on white and shows a white fringe on anything darker. If your cut-out will sit on dark backgrounds, export it with full alpha instead.
Masks, mattes and alpha: the vocabulary
These words overlap and get used loosely. Here is how they are usually meant:
- Alpha channel: the opacity values stored inside an image file, one per pixel.
- Mask: a grayscale image that controls which parts of another image are visible. In Photoshop's layer masks, white reveals and black conceals, and grays are partly visible. A mask can be edited without touching the original pixels, which is why professionals remove backgrounds with masks rather than by erasing.
- Matte: the film and compositing term for the same idea, a grayscale image that defines what is kept. "Matting" is the problem of computing soft, accurate mattes for difficult edges like hair.
- Trimap: a rough three-zone map (definitely foreground, definitely background, unsure) that some matting algorithms use as a starting point.
- Binary or hard mask: only black and white, no grays. Fine for boxes and logos, poor for hair.
- Cut-out: the finished result, the subject's colors plus an alpha channel.
A mask and an alpha channel hold the same information. Many tools let you export either: a transparent PNG with the alpha built in, or a separate black and white mask image you can apply yourself in an editor or a video tool.
Which formats can store alpha
| Format | Alpha support |
|---|---|
| PNG | Full alpha (8 or 16 bits), or a single transparent palette color |
| WebP | Full alpha, in both lossless and lossy modes |
| AVIF | Full alpha |
| GIF | On or off only: one palette color marked transparent |
| JPEG | None |
For a full comparison of these formats, see PNG vs JPEG vs WebP.
How to check whether an image has transparency
A file ending in .png is not proof of transparency. Many PNGs are fully opaque, and some "transparent" images found online are JPEGs with a gray and white checkerboard painted into the pixels. Here are reliable ways to check.
By eye
Place the image on a dark background and on a light one, for example in a slide or a design tool. A real cut-out shows the background color around the subject in both cases. If you still see a checkerboard, it is part of the picture, not transparency.
With ImageMagick
# Does the file have an alpha channel at all?
identify -format "%A\n" photo.png
# Is it fully opaque anyway? (true means no visible transparency)
identify -format "%[opaque]\n" photo.png%A reports the transparency channel (the exact word printed differs between ImageMagick 6 and 7), and %[opaque] calculates whether every pixel is fully opaque. You want an alpha channel and false.
With Python and Pillow
from PIL import Image
im = Image.open("photo.png")
print(im.mode) # RGBA or LA means an alpha channel
print(im.has_transparency_data) # True if the file carries any transparency info
if "A" in im.getbands():
lo, hi = im.getchannel("A").getextrema()
print("alpha range:", lo, hi) # lo == 255 means nothing is transparentThe extrema check catches the common case of an RGBA file in which every pixel is opaque.
When the platform ignores alpha
Some places strip or ignore transparency. Etsy says transparent PNGs are not supported and transparent areas can show up black, and marketplaces such as Amazon and Walmart want main images on pure white anyway. In those cases, flatten the cut-out onto the background color yourself so you control the result. On your own website, in slides and in design tools, keep the alpha.
Getting a clean alpha channel quickly
If you need cut-outs with soft edges rather than hard masks, removebackground.dev produces transparent PNG or WebP files with a full alpha channel, and its API can also return the grayscale mask on its own.
Questions
What does RGBA mean?
Red, green, blue and alpha. The first three describe a pixel's color and the fourth describes its opacity, from 0 (fully transparent) to the maximum value (255 in 8-bit images) for fully opaque.
What is the difference between straight and premultiplied alpha?
Straight alpha stores a pixel's full color and its opacity separately. Premultiplied alpha stores the color already multiplied by the opacity, as if it had been composited on black. PNG always uses straight alpha; many rendering and video tools use premultiplied internally.
Why does my cut-out have a white or colored outline?
Usually the old background is still mixed into the edge pixels, or the image was antialiased against white before saving. Decontaminating edge colors, using a soft mask, and exporting with full alpha instead of a matte color fix most cases.
Is a mask the same as an alpha channel?
They hold the same information: a grayscale value per pixel saying how visible it is. An alpha channel is stored inside the image file; a mask is usually a separate grayscale image or a layer mask in an editor.
How do I know if a PNG is really transparent?
Place it on a dark and a light background and check that the background shows through. Or run ImageMagick's identify with %[opaque], or check the alpha channel's minimum value in Pillow; a minimum of 255 means nothing is transparent.
Try it on your own image
New accounts get 50 free credits. One credit per image, no subscription, and credits never expire.
Remove a backgroundSources
- MDN: Alpha (alpha channel) glossary entry
- W3C: Portable Network Graphics (PNG) Specification (Third Edition)
- W3C: Compositing and Blending Level 1, simple alpha compositing
- MDN: Image file type and format guide
- Adobe Help: Select and Mask in Photoshop
- Adobe: Remove background with AI in Photoshop (layer masks)
- rembg README: color decontamination and edge modes
- ImageMagick: Format and print image properties (escapes)
- Pillow: Image module reference
- Etsy Help: Requirements and best practices for images in your Etsy shop