Rekha

Why traced gradients look banded, and how to keep them smooth

Most tracers turn a smooth fade into a stack of flat stripes. Here is why that happens and how fitting a real SVG gradient avoids it.

Trace a logo with a soft fade in most image-to-SVG tools and the fade comes back as stripes: ten or twenty flat bands where there was one smooth blend. Those banded gradients are the commonest reason a traced file gets thrown away and redrawn. It is worth understanding why they happen, because the cause points straight at the fix.

Why does tracing turn a gradient into bands?

A classic colour tracer works in two steps. First it reduces the image to a small set of colours. Then it draws an outline round every area of each colour.

A gradient breaks the first step. A fade from blue to teal contains hundreds of slightly different colours, and the tracer has to squeeze them into a handful. Every pixel is rounded to its nearest allowed colour, so the smooth fade becomes a staircase. The second step then outlines each stair faithfully. The tracer has done exactly what it was built to do, and the result is stripes.

Why can’t I just use more colours?

You can, and the stripes get narrower. They do not go away, and the price is steep:

  • More shapes. Every band is a path. A shaded logo can reach hundreds.
  • Bigger files. Each of those paths carries its own curves.
  • Visible seams. Renderers anti-alias each band on its own, so faint lines appear between neighbours, most of all when zoomed or printed.
  • Nothing to edit. Changing the colour of a fade means recolouring forty strips by hand.

More colours treat the symptom. The real mistake is describing a gradient as flat shapes in the first place.

What is the alternative?

SVG has gradients built in. One shape can be filled with a linearGradient that runs between two points, or a radialGradient that spreads from a centre, with as many colour stops as needed. It is how the artwork was almost certainly drawn before it became a PNG.

So the better approach is to work backwards: notice that a run of bands is really one ramp, merge the bands into a single region and fit one gradient to the pixels underneath.

How does Rekha fit a gradient?

Roughly like this:

  1. Trace the bands as usual, so there is something to reason about.
  2. Look for neighbours that step in a steady direction. Bands whose colours follow one ramp belong together.
  3. Merge them into one region and fit a gradient to the original pixels, with stops wherever the ramp bends. If the bands run round a centre, the fit is radial.
  4. Check the error. If the gradient does not reproduce the pixels closely enough, the bands stay as they were. Flat artwork is left untouched.

Some shading is more than one gradient. A glossy ball has a fade across its body and a highlight off to one side. Rekha paints that the way an illustrator would: a base gradient with one or two translucent radial gradients layered on top.

What difference does it make?

On a 16-megapixel illustration in Rekha’s benchmark, turning gradients on took the trace from 155 flat paths to 82, made it measurably closer to the source, and cut the file size by 60 %.

Against another converter the gap is wider. On a logo with radial shading, Rekha produced 33 paths in 32 kB. Adobe Express produced 197 paths in 325 kB and matched the source less closely. The full comparison has the figures and the method.

How do I keep gradients smooth in my own traces?

  • Use a tracer that fits gradients. In the studio, Auto tries a gradient fit and keeps it when it is the closest match. On the command line it is --gradients.
  • Start from a clean source. JPEG noise breaks up a ramp. A PNG, or a JPG with clean-up on, gives the fit a fair chance.
  • Do not cap the colours too low. The tracer needs enough bands to see the direction of the ramp before it can merge them.
  • Check the outline view. A fade should be one shape. If you can see stripes in the outline, the gradient was not fitted.

Common questions

Does SVG support gradients?

Yes, linear and radial, with any number of colour stops and with transparency. Every modern browser and vector editor reads them.

Will the gradient survive in PDF and EPS?

In PDF, fully, including translucent layers. EPS has no transparency, so layered highlights are left out there while the base gradients remain.

Can I edit a traced gradient afterwards?

Yes. It is an ordinary SVG gradient, so you can move its ends and change its colours in Illustrator, Figma or Inkscape.

Keep reading