Guide

Why a smooth gradient develops bands after compression

Our smallest 16-colour PNG was 1,254 bytes and showed broad bands across the blue gradient. Keeping full colour needed 2,067 bytes, only 813 more. JPEG quality 80 cost 8,019 bytes, almost four times the full-colour PNG, and introduced steps that the PNG did not have.

Last updated:

Bitinz team · How we write and check our content

A newsletter header with a gradient background

The gradient was the background of a newsletter header we made. Its headings stayed HTML text, so only the background changed between versions.

16-colour PNG background

A newsletter header card whose blue gradient background shows vertical bands.

CSS gradient

The same header card with a smooth CSS gradient background.
Look behind the headings. The reduced-palette PNG has broad vertical bands; the CSS gradient uses the same end colours without them.

A gradient with a known starting point

The source was a 1200 × 360 horizontal gradient from RGB (24, 40, 64) to (76, 116, 168), interpolated in sRGB values. We generated it directly with 16-bit channel samples, then made an 8-bit truecolour PNG without dithering. That version contained 225 distinct colours.

An indexed PNG can hold up to 256 colours, enough to keep this 8-bit image exactly. A 256-colour export kept all 225 colours and every decoded RGB byte, but at 3,575 bytes it was larger than the 2,067-byte truecolour file.

We then deliberately chose a much lower limit of 32 colours to make the loss of intermediate colours easy to see. ImageMagick picked 16 for this input. Both reduced-palette versions used that same palette, once without dithering and once with Floyd–Steinberg dithering.

The tools were ImageMagick 7.1.1-47 Q16-HDRI, libjpeg-turbo 3.2.0 and libwebp 1.6.0. Browser comparisons on 2026-11-16 used Google Chrome 157.0.8103.78 on macOS 27.0.1, forced to sRGB at a device pixel ratio of 1.

Version, all 1200 × 360Bytes
16-bit truecolour PNG4,250
8-bit truecolour PNG2,067
Indexed PNG, all 225 colours kept3,575
16 colours, no dithering, 8-bit indices2,480
16 colours, dithering, 8-bit indices78,372
16 colours, no dithering, 4-bit indices1,254
16 colours, dithering, 4-bit indices78,794
JPEG, quality 80, 4:4:48,019
Lossy WebP, quality 80, method 41,404
8-bit PNG with slight noise208,038
Noisy source as JPEG, quality 808,470
Noisy source as WebP, quality 801,422

PNG exports used compression level 9 with metadata removed. Each lossy file was encoded from its named source, not from another JPEG or WebP.

A smaller palette made broad bands

With only 16 colours available, the version without dithering gave long stretches of the image one colour before switching to the next, and the boundaries were clear at normal size. PNG kept the pixels it was given, bands included.

16-bit PNG · 4,250 bytes

A smooth blue gradient strip from the 16-bit PNG.

8-bit PNG · 2,067 bytes

A smooth blue gradient strip from the 8-bit PNG.

16 colours, no dithering · 1,254 bytes

The gradient reduced to 16 colours, with broad visible bands.

16 colours, dithering · 78,794 bytes

The gradient reduced to 16 colours with dithering, smooth but grainy.
The same central strip of each file. Compare the two upper strips with the solid bands of the third; the fourth breaks those boundaries up with a stippled transition.

Dithering arranged neighbouring palette colours in a pattern; it did not add colours to the palette. The enlarged detail shows the pattern replacing the flat boundary.

16 colours, no dithering

An enlarged detail with two flat blue areas meeting at a straight edge.

16 colours, dithering

The same detail with dithering, showing a pattern of light and dark pixels.
The same 200 × 80 region of both files, enlarged three times without smoothing: a straight boundary above, a scatter of lighter and darker pixels below.

The dithered file with 4-bit indices was 62.8 times the size of its undithered counterpart. Packing indices into 4 bits cut the plain file from 2,480 to 1,254 bytes but made the dithered file slightly larger. For each treatment, 4-bit and 8-bit indices decoded to identical pixels.

On this quiet background the dither pattern was visible in its own right. The PNG specification describes the trade-off: “For photograph-like images, dithering is recommended to avoid ugly contours in what should be smooth gradients; however, dithering introduces graininess that can be objectionable.”

JPEG and WebP added steps of their own

The clean 8-bit PNG changed by fine steps across the ramp. JPEG at quality 80, even with 4:4:4 sampling, introduced wider flat areas and more abrupt boundaries, and it was 3.9 times as large: 8,019 bytes against 2,067.

WebP was smaller at 1,404 bytes, but it also showed steps. The enlarged crops below come from the decoded files.

8-bit PNG · 2,067 bytes

An enlarged gradient detail from the 8-bit PNG with fine, even steps.

JPEG · 8,019 bytes

The same detail from the JPEG, with wider steps.

WebP · 1,404 bytes

The same detail from the WebP, with wider steps.
Follow the transition from left to right. The PNG's fine progression becomes broader steps in the JPEG and WebP crops, all taken from the same region and enlarged the same way.

For this smooth synthetic background, JPEG was both larger and less smooth than the full-colour PNG, and WebP saved bytes at the cost of visible steps. Compare a truecolour PNG before choosing either.

Noise made the PNG about 100 times larger

We made another 8-bit source with fixed random noise: at each pixel, an adjustment of −1, 0 or +1 was applied to all three channels.

Stored exactly as PNG, those noisy pixels cost 208,038 bytes, about 100 times the clean version's 2,067. The JPEG files cost 8,019 and 8,470 bytes without and with noise, and the WebP files 1,404 and 1,422.

8-bit PNG · 2,067 bytes

The smooth 8-bit PNG gradient strip.

JPEG · 8,019 bytes

The JPEG gradient strip with faint steps.

WebP · 1,404 bytes

The WebP gradient strip with faint steps.

PNG with slight noise · 208,038 bytes

The noisy PNG gradient strip with a fine grain.

JPEG with slight noise · 8,470 bytes

The noisy source saved as JPEG, still with steps.

WebP with slight noise · 1,422 bytes

The noisy source saved as WebP, still with steps.
The clean PNG comes first for reference. The noisy PNG has a fine grain; the clean and noisy lossy files both keep uneven steps.

This much noise did not remove the steps from the final JPEG and WebP files. If you try noise as a fix, check the exported file, not the editor preview.

A CSS background needed no image request

The browser could draw the newsletter background itself. We tested:

background: linear-gradient(to right in srgb, #182840, #4c74a8);

The declaration is 64 characters, and the page does not request a background image for that panel. in srgb tells the browser to mix the two colours in the same colour space as our image gradient.

Chrome accepted the syntax, and the CSS panel avoided the coarse palette bands in our screenshot. CSS Images 4 lets browsers dither gradient colours slightly to make them smoother. Keep a design background in CSS when that suits the page, and check the real rendering at the sizes people use.

Check the colours before reducing them

Keep the source and compare each export at 100% before enlarging the same region. Look for long flat areas, abrupt boundaries and fine patterns.

We verified this command for the dimensions, reported depth and number of colours:

magick identify -format '%f %wx%h depth=%z colours=%k\n' gradient.png

Start with %k. An 8-bit image with no more than 256 colours fits completely in an indexed PNG, so try an export that keeps them all and compare its size with truecolour PNG; our lossless indexed version was larger. With more colours, as in a wider-range gradient, a two-dimensional gradient or a photograph, a 256-entry palette means reducing colours.

For a controlled dithering comparison, make the palette once and remap the same source twice:

magick gradient.png -quantize sRGB +dither -colors 32 \
  -unique-colors -depth 8 palette.png
magick gradient.png +dither -remap palette.png -strip \
  -define png:compression-level=9 PNG8:no-dither.png
magick gradient.png -dither FloydSteinberg -remap palette.png -strip \
  -define png:compression-level=9 PNG8:dither.png

These exports use 8-bit indices. We also verified 4-bit indices with -define png:color-type=3 -define png:bit-depth=4: packing saved space in the plain file but did not bring back its missing colours, while full colour cost only another 813 bytes and avoided the bands.

If you compress the final PNG or use any other tool such as Bitinz, compare the same region at 100% afterwards. For PNG sizes in general, see how to reduce PNG file size, and for the wider trade-off, lossy vs lossless compression.

Compress imagesMake JPG, PNG and WebP files smaller in their own format, in batches and for free.Compress images

What we did not test

Physical displays and HDR were outside this test, and we used one Chrome version. We did not test stronger noise, photographs or printed output.

FAQ

Should I save a gradient background as JPEG?
Try full-colour PNG or a CSS gradient first for a smooth synthetic background. Our JPEG was almost four times larger than the PNG and introduced visible steps. If you use JPEG anyway, compare the final export with the original gradient at the actual display size.
Why can a PNG show bands if PNG is lossless?
Check whether the export reduced the colours or channel precision before writing the PNG. Lossless storage keeps the resulting pixels, bands included. Export a truecolour copy from the original and inspect the same region.
Should I add noise to hide bands?
Try it on a copy and inspect the final export. Our slightly noisy PNG became about 100 times larger, and the JPEG and WebP versions still had steps. For a page background, test CSS before adding texture to an image.
Can converting a banded file to 16-bit fix it?
No. Go back to the high-precision source or recreate the gradient. A larger storage depth cannot rebuild intermediate values that were already removed, so keep that source while you choose the export.

Tools in this guide

Sources

  1. Bitinz: Gradient banding test: files, measurements and commands (2026-11-16)
  2. W3C: PNG Specification (Third Edition): truecolour image handling
  3. ImageMagick: Command-line options
  4. W3C: CSS Images Module Level 4: coloring the gradient line