The artifact needs transparency
JPEG has no alpha channel. A card meant to sit on an unknown background has to be PNG, or the transparent area is flattened - usually to black or white, decided by the encoder rather than by you.
Generated artifacts are not photographs and they are not screenshots of photographs. A social card, an invoice or a badge is mostly flat colour and text, which is the exact content JPEG compresses worst and PNG compresses best - and the moment a photograph or a wide gradient enters the same card, that reverses.
Text picks up a halo of grey speckle at the edges of glyphs, or a 1200x630 card leaves the renderer as a multi-megabyte PNG that a CDN then serves on every page view.
Do not choose from a rule of thumb. Encode the artifact you actually ship in both formats, print the byte sizes, and keep the smaller one that survives inspection at the size it will be displayed.
const page = await browser.newPage({ viewport: { width: 1200, height: 100 } });
await page.setContent(card, { waitUntil: "load" });
await page.evaluate(() => document.fonts.ready);
const png = await page.screenshot({ type: "png", fullPage: true });
const jpeg = await page.screenshot({ type: "jpeg", quality: 80, fullPage: true });
console.log("png ", (png.length / 1024).toFixed(1), "KiB");
console.log("jpeg ", (jpeg.length / 1024).toFixed(1), "KiB");
// Flat colour and text: the PNG is usually smaller AND lossless.
// A photograph or a wide gradient: the JPEG is usually several times smaller.The call above is small. Everything around it is the system — and the system is what you would be signing up to own.
JPEG has no alpha channel. A card meant to sit on an unknown background has to be PNG, or the transparent area is flattened - usually to black or white, decided by the encoder rather than by you.
A hero image or a wide smooth gradient makes PNG expensive: lossless compression cannot exploit the redundancy JPEG was designed for. Here the same perceived quality can cost several times fewer bytes as JPEG.
Doubling device scale roughly quadruples the pixel count. A PNG that was acceptable at 1x can stop being acceptable at 2x while the JPEG at the same density stays reasonable.
If the artifact is large because the layout is 6000 pixels tall, no format choice fixes it. Bound the height or capture the element instead of the document.
One file in the format you asked for, at the width you set and as tall as the markup, encoded by the same Chromium build every time.
One successful, non-cached capture costs one credit. Failures, including platform failures, cost zero; cache hits cost zero.
A tall document at a high pixel density produces an artifact past the size limit - the usual cause is density, not format.
HTTP 400 · terminal
The inline markup carries large embedded data URLs and the request 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; 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 the alpha channel and the lossless compression this guide relies on.
Documents the type and quality options used by the DIY comparison.
The lossless side of the comparison, with transparency and pixel density as controls.
The lossy side, where quality is the only knob that matters.
What the alpha channel does to the file, and which formats keep it.
Every encoding parameter, with its default and range.