UpMaths
中文
Format decisions12 min read·Updated 2026-10-27

PNG or JPG: a table by use case, with measured size and quality data

This question has ten thousand answers, and most of them stop at “photos use JPG, icons use PNG” — correct, but not enough to decide about the file in front of you. Here three test images go through seven format settings, and the argument is made with bytes and pixel-level error: when JPEG saves 80%, and when it saves 18% while damaging the edges of your text.

1. Start with the table: which kind of image do you have?

Do not reason from the format. Reason from what is inside the image. A compression algorithm only works on one kind of content, and the deciding factor is not file size but the statistical character of the pixels.

What is in the imageSave asWhy
Continuous tone: portraits, landscapes, product shots, scanned photosJPEGHigh-frequency content is dense and irregular, so quantising it away is invisible. Measured: 18% of the PNG size
Sharp edges: screenshots, text, table rules, code, UI, chartsPNGLarge flat areas plus extremely sharp edges — precisely JPEG's worst case. Measured: saves only 18%, and 870 pixels altered
Needs transparency: logos, icons, stickers, cut-outsPNG (or WebP)The JPEG specification has no alpha channel; transparent areas get filled with a solid colour
Web imagery, and you can accept a browser baselineWebP26% smaller than JPEG at comparable quality, with transparency support. Every browser since 2020 reads it
For print, for hand-off, or for further editingPNG or TIFFNo lossy step should be introduced at the delivery stage; let the printer or retoucher do the last step
Sending originals in a chat app, or an attachment under a size limitJPEG quality 0.8512% of the PNG size, visually indistinguishable — the standard answer to “the file is too big to send”

The one-line rule

Does the image contain a structure that jumps from black to white across a single edge? Then PNG. Does it contain large areas of slowly shifting colour? Then JPEG. If it has both — a landscape photo with a caption burned in — save two versions, or use WebP.

The underlying reason is that the two formats compress in opposite ways. PNG does lossless predictive coding: extremely efficient on repeated flat areas, nearly helpless against noise where every pixel differs. JPEG does lossy frequency-domain quantisation: it cuts the image into 8×8 blocks, applies a cosine transform, and discards high frequencies according to human sensitivity — hence excellent on continuous tone, and visibly ringing on sharp edges.

2. How these numbers were produced

Every figure below is measured, not quoted. The method is stated in full so you can reproduce it, or run it against your own images.

  • Encoder: Chrome's built-in canvas.toBlob — the same interface every browser-side “local conversion” tool actually calls. Not Photoshop, not ImageMagick. This matters: numbers from a command-line tool will differ.
  • Test image A (photo, 1920×1280): continuous colour gradients over three layers of noise at different scales, approximating the spectrum of a natural scene.
  • Test image B (screenshot, 1920×1280): solid blocks, 52px Chinese text, 1px table rules — approximating an exam screenshot or a UI capture.
  • Test image C (alpha, 800×800): circular logo, fully transparent corners.
  • Quality metric 1: PSNR in dB, higher is closer to the original. Above roughly 38 dB the difference is invisible; around 32 dB it becomes noticeable on inspection.
  • Quality metric 2: obviously wrong pixels — pixels where one channel deviates by more than 48 levels (about 19%). PSNR is a global average and scores “a small area destroyed” the same as “everything slightly shifted”; this metric catches the former.

Why synthetic images instead of real photos

Real photographs differ so much in spectrum that one cat photo and one landscape can differ twofold in size; anyone testing their own file against your number would disagree. A synthetic image with parameters fixed in code is the same file for everyone, and the numbers can be compared digit by digit. So do not extrapolate the absolute values to your own photos — what transfers is the relationship between the three image types, and that relationship is stable.

3. Photos: JPEG reaches 18% of the size, and costs 38 dB

Test image A, identical canvas content, encoded at several settings:

Format and settingSizeShare of PNGPSNR
PNG (lossless)4.75 MB100%lossless
WebP quality=1.0 (lossless)2.62 MB55.3%lossless
WebP quality=0.92859 KB17.7%42.24 dB
JPEG quality=0.92882 KB18.2%38.01 dB
JPEG quality=0.85582 KB12.0%34.09 dB
JPEG quality=0.75363 KB7.5%32.43 dB
WebP quality=0.80500 KB10.3%36.05 dB

Three results deserve separate attention.

First, PNG is nearly useless for photos. 4.75 MB lossless, against 882 KB of JPEG at 38 dB, where the difference is already invisible. That 5.4× gap is why “PNG is better for photos” is wrong — PNG was never good for photos; it is merely harmless to them.

Second, WebP is genuinely smaller at equal quality, but by less than the marketing implies. At quality=0.92 WebP gives 859 KB at 42.24 dB versus JPEG's 882 KB at 38.01 dB. WebP buys a better PSNR for fewer bytes; raise JPEG's quality to the same PSNR and the sizes roughly converge. The real gap opens at low bitrates: around 10% of the PNG size WebP still holds 36 dB while JPEG has fallen to 32.4 dB.

Third, lossless WebP is 55% of the PNG size — a practical finding. 2.62 MB against 4.75 MB with zero quality loss: if you need “lossless, but smaller than PNG”, this is the only option that does not require changing format family.

4. Screenshots and text: JPEG saves 18% and damages 870 pixels

Same settings, now with test image B (solid blocks, Chinese text, 1px rules):

Format and settingSizeShare of PNGPSNR
PNG (lossless)161 KB100%lossless
JPEG quality=0.92132 KB81.7%42.35 dB
JPEG quality=0.85108 KB67.1%41.09 dB
JPEG quality=0.7590.9 KB56.3%39.76 dB
WebP quality=0.9265.0 KB40.3%43.41 dB

The same 1920×1280 canvas: for photos JPEG reaches 18% of the PNG size, for screenshots only 81.7%. What did those 29 KB buy? Look at the pixel-level numbers:

Format and settingPixels off by >20Pixels off by >48Share
JPEG quality=0.929,6608700.393% / 0.035%
JPEG quality=0.8512,2191,1360.497% / 0.046%
JPEG quality=0.7522,9961,4780.936% / 0.060%
WebP quality=0.929,1085860.371% / 0.024%

870 pixels — and they are not scattered evenly. They cluster on both sides of glyph strokes and table rules, which is exactly where JPEG's 8×8 block boundaries land. This is ringing: a grey gradient appears where there was none, and a clean 1px rule becomes a grey band three or four pixels wide.

At 100% zoom the effect is text turning fuzzy, thin rules turning dashed, and a dirty fringe along the boundary between the blue header and the white background. At thumbnail size none of it is visible — which is why this damage passes review so often.

PSNR fails here

Screenshot JPEG scores 42.35 dB, higher than the photo's 38.01 dB. Reading PSNR alone, you would conclude that JPEG is better for screenshots — the opposite of the truth. More than 90% of a screenshot is flat white that stays flat white, contributing zero error and dragging the average up, while the severe damage to the remaining edges is averaged away. Quality cannot be judged by a single number; you have to look at where the error sits.

The conclusion is blunt: screenshots, exam papers, code captures, charts — save as PNG. If you need smaller, use lossless WebP (quality=1.0, see section 8), not JPEG.

5. Transparency: JPEG does not have the capability at all

This is not a matter of JPEG handling transparency poorly. There is no alpha channel in the JPEG file structure. Hand a four-channel RGBA image to a JPEG encoder and the fourth channel is discarded, with transparent areas composited onto some solid colour — white or black depending on the tool's fill strategy, which is why the same transparent logo can come back on different backgrounds from different sites.

Test image C (800×800, transparent corners), measured:

Format and settingSizeShare of PNGAlpha preserved
PNG (lossless)50.2 KB100%yes
WebP quality=0.9224.0 KB47.8%yes (0 pixels changed in the alpha channel)
WebP quality=0.8019.1 KB38.0%yes
JPEG (any setting)——not supported

WebP preserves alpha while cutting size to 48% of PNG — its least arguable advantage over PNG. If the transparent image only lives on the web and in modern apps, WebP is the better choice. If it has to be sent to someone, or dropped into Word or PowerPoint, stay with PNG: support there is still unreliable.

6. Does re-encoding really degrade an image step by step?

“Every save loses a little quality, ten saves and it's destroyed” is widely repeated, and it is not accurate. I re-encoded the photo test image eight times, alternating between 0.92 and 0.75 — the pattern closest to real mishandling: save once large, get compressed in transit, save again:

RoundSetting usedSizePSNR vs original
10.75363 KB32.43 dB
20.92464 KB32.47 dB
30.75363 KB32.40 dB
40.92462 KB32.45 dB
50.75363 KB32.39 dB
60.92462 KB32.44 dB
70.75363 KB32.38 dB
80.92462 KB32.43 dB

PSNR oscillates between 32.38 and 32.47 dB with no cumulative degradation after eight rounds. Size behaves the same way, settling from round three onwards at two values, 363 KB and 462 KB — the file has converged to a fixed point.

The mechanism is straightforward. JPEG discards high-frequency detail in the DCT coefficients by quantising: divide each coefficient by a step size and round. After the first pass the coefficients sit on quantisation grid points; apply the same step size again and they barely move. The loss is single-shot, roughly equal to the worst quality setting you used, not additive.

Which does not mean you can re-encode freely

The loss does not accumulate, but it is one-time and irreversible. The first round above took PSNR from lossless to 32.43 dB, and nothing brings it back. The right rule is not “it doesn't add up anyway” but “compress once, at the end, at a quality high enough to keep”. Repeated encoding also keeps eroding 8×8 block boundaries — invisible in PSNR, but block edges gradually become obvious on large flat backgrounds.

7. Converting back to PNG restores no quality, only the file size

A common rescue idea is “convert the JPEG back to PNG and it becomes lossless again”. Measurement says no:

File stateSizeShare of original PNGPSNR vs original
Original PNG4.75 MB100%lossless
Converted to JPEG quality=0.92882 KB18.2%38.01 dB
Converted back to PNG3.87 MB81.5%38.01 dB (unchanged)
That PNG converted to JPEG 0.92 again882 KB18.2%38.01 dB

Rows two and three are the point: size goes from 882 KB to 3.87 MB, a 4.4× increase, while PSNR sits at 38.01 dB without moving. Converting to PNG only re-wraps the information that survived in a more expensive container; what was discarded does not come back.

The practical corollary: format conversion only helps at the first encoding. If all you have is an already-compressed JPEG, converting it to any lossless format simply buys storage cost. Find the original, or accept the current state.

8. Choosing the quality value: 0.92 is a good default, 1.0 has a trap

The quality argument of canvas.toBlob is a decimal from 0 to 1, and it does not mean the same thing as Photoshop's “Quality 92”. Chrome maps 0.92 onto one of its own JPEG quantisation presets, and the mapping differs between browsers and versions. The same 0.92 can produce files more than 10% apart in size in Chrome, Firefox and Safari. That is why “you say 0.92 gives 882 KB but I get 1.1 MB” does not necessarily mean anyone measured wrong.

PurposeSuggested valueReason
Web imagery (photos)JPEG 0.8512% of the lossless size, invisible even on a large display
Intermediate file for further editingJPEG 0.92 or PNGLeave yourself room; do not compress in the middle of a workflow
Final delivery to a clientJPEG 0.92 / PNGThe client may zoom; 0.85 shows on text-heavy images
Smaller and transparentWebP 0.9226% below JPEG, alpha preserved
Genuinely losslessWebP 1.0, not WebP defaultSee the trap below

A real trap: WebP without a quality value is not lossless

Measured on the same photo: canvas.toBlob with no quality argument returned 500 KB at 36.05 dB, lossy; passing 0.8 returned the identical 500 KB; only 1.0 produced 2.62 MB with infinite PSNR, i.e. true lossless. So “WebP is a lossless format” holds only at quality=1.0. Many tools advertising “lossless WebP conversion” are in fact emitting 0.8 lossy output. The check is simple: convert the result back to PNG and compare pixel by pixel — lossless means identical.

9. Run this checklist before you deliver the file

  1. Will this image be viewed enlarged? If so, do not go below JPEG 0.75 — and for text content, do not use JPEG at all.
  2. Is there transparency? Confirm the output is PNG or WebP, and open it in the target application (Word, PowerPoint and some CMSs handle WebP unreliably).
  3. Are there thin rules or small type? Zoom to 100% and check for grey fringing and 8×8 block artefacts.
  4. Will this be printed? Use PNG or TIFF and let the printer take the last step; JPEG is acceptable only above 0.92 and at sufficient resolution.
  5. Is the file too large to send? Try JPEG 0.85 first, which is usually enough; if not, reduce dimensions rather than quality — resizing is less visible than compression.
  6. Is this a JPEG someone else already compressed? Do not expect PNG to restore it. Use it as is, or ask for the original.
  7. Archiving long term? PNG or lossless WebP. Storing in a lossy format for ten years fixes an irreversible decision inside the file.

Frequently asked

Why is my file size so different from your numbers for the same photo?

Three reasons. Image spectrum differs — two real photos can differ by more than 2×, while this article used a synthetic image with fixed parameters. The encoder differs — Chrome's canvas, Photoshop, ImageMagick and libjpeg-turbo map the same quality value onto different quantisation tables. And the meaning of quality is not standardised — the same 0.92 can produce files more than 10% apart across browsers. Compare trends, not absolute values.

Can PNG be compressed further?

Yes, with little headroom. PNG is lossless, so the compression ratio depends entirely on redundancy in the content: flat screenshots compress well, noisy photos barely at all. Professional tools offer lossy PNG reduction by lowering the colour depth to 256 colours, which changes the image and is no longer lossless. For a genuinely smaller lossless file, use WebP quality=1.0 — measured at 55% of PNG.

My screenshots are hundreds of KB each as PNG. What should I do?

Two directions. Save as WebP quality=1.0, measured at roughly 40% of PNG with no loss at all. Or reduce dimensions first: a 1920-wide screenshot at 1280 wide is about 44% of the size and looks identical on screen. The worst option is JPEG, which saves only 18% and grows grey fringes around the text.

Is JPEG quality=0.92 the same as Photoshop's Quality 92?

No. Photoshop's 92 maps onto its own quantisation table; the browser's 0.92 is a different mapping. Both being called 92 is coincidence, and both size and quality differ. Any strict comparison has to fix the encoder.

My transparent image turned white (or black) as JPEG. Can it be recovered?

No. The alpha channel is discarded at the moment the JPEG is created; converting that file to PNG later only places an opaque image inside a PNG container. The only fix is exporting again from the original. Different tools fill with different colours — white or black — which is why the same logo can come back on different backgrounds.

Why does a screenshot score a higher PSNR as JPEG than a photo?

More than 90% of a screenshot is flat colour that stays flat after compression, contributing zero error and pulling the global average up, while severe damage concentrates on text and line edges making up under 1% of pixels. PSNR is a global metric and is insensitive to localised destruction; text images must be judged on magnified edges or localised error statistics.

Will re-saving a JPEG ten times ruin the photo?

Far less than the folklore suggests. Over eight rounds alternating 0.92 and 0.75, PSNR held steady around 32.4 dB with no cumulative degradation, because quantisation snaps coefficients to grid points and later passes barely move them. But the first pass is permanent and irreversible — so the rule is “compress once, at the end, at high enough quality”, not “it doesn't accumulate, so anything goes”.

How does the HEIC from an iPhone relate to JPEG and PNG?

HEIC is another lossy format, about 40% more efficient than JPEG, but it is essentially a single frame of HEVC video and compatibility is poor: Windows will not open it by default, and many sites refuse the upload. The usual handling is converting to JPEG for sharing, or PNG for further editing. That is a separate topic and will get its own article here.

Tools mentioned above

Read next

PNG or JPG — a decision table with measured size and quality data | UpMaths