The format has no alpha channel
JPEG cannot store transparency at all, and asking for it there is not a partial result — the transparent area is filled with whatever the encoder decides, usually white or black.
A browser window is not transparent. Even when every element in the document declares a transparent background, the renderer paints an opaque canvas underneath before it paints anything of yours — so an image captured from it is opaque unless the capture explicitly asks otherwise.
A logo, badge or card exported for use over an unknown background arrives with a white rectangle around it, and the CSS inspector insists the background is transparent.
getComputedStyle(document.body).backgroundColor in the page: a CSS reset or a framework base layer often sets it to an opaque value that no rule of yours mentions.Clear the background on the document as well as on the element, ask the renderer to skip its own canvas, and write to a format that has an alpha channel.
await page.setContent(card, { waitUntil: "load" });
// The document, not only the element: a reset stylesheet is the usual culprit.
await page.addStyleTag({ content: "html,body{background:transparent!important}" });
const opaque = await page.evaluate(() => getComputedStyle(document.body).backgroundColor);
if (opaque !== "rgba(0, 0, 0, 0)") throw new Error(`body still paints ${opaque}`);
await page.locator("#card").screenshot({
path: "card.png", // png, not jpeg: the format has to be able to hold alpha
omitBackground: true, // without this the renderer paints white underneath
});The call above is small. Everything around it is the system — and the system is what you would be signing up to own.
JPEG cannot store transparency at all, and asking for it there is not a partial result — the transparent area is filled with whatever the encoder decides, usually white or black.
Normalize and most framework base layers set an opaque background on body. Your element being transparent does not help when the surface behind it is not.
A thumbnailer, an email client or an image pipeline that re-encodes to JPEG removes the alpha after you produced it correctly. The failure is downstream of the capture.
Many previews composite transparency onto white, so a correct file and a broken one look identical until you open it over a checkerboard or a coloured surface.
A PNG whose transparent regions are genuinely empty, so the artifact composites over any background instead of carrying a rectangle of its own.
One successful, non-cached capture costs one credit. Failures, including platform failures, cost zero; cache hits cost zero.
The requested format has no alpha channel and the request asks for the background to be omitted.
HTTP 400 · terminal
The inline markup embeds large data URLs and the body passes the limit.
HTTP 413 · terminal
Swap the example for a page you care about. The runner keeps every option from this guide, and carries the whole configuration into the playground — no retyping, no starting over.
Written by PageCapture Engineering. Reviewed by PageCapture render maintainers. Verified 2026-08-26 by running the published code against a fixture.
The recipe was normalized through the public contract and its markup rendered with the pinned Chromium build, with and without the omitted background; the CI fixture run has not executed this piece yet.
Sources support the browser and API behaviors named above. PageCapture-specific limits and billing are taken from the public contract; external sources are used for the underlying browser behavior.
Defines alpha compositing and the transparent keyword this guide relies on.
Documents the omitBackground option used by the DIY fix.
The same two halves of the fix as a form: PNG output and the background left off.
Type, default and which formats accept it, straight from the parameter contract.
Keeping transparency forces a lossless format, and that decision has a price in bytes.
Every encoding parameter next to the one this guide turns on.