1

I have an SVG with gradients. Postprocessing it with GIMP 2.8 produced banding due to its rasterization which is only 8bit/channel. I downloaded Gimp 2.10, then set channel precision 16bit, imported directly from Inkscape as SVG, yet the banding was there as before. Then I installed Inkscape 1.0.1, exported as 16bit PNG, imported to Gimp 2.10. Gimp shows 16bit/channel, but the banding is still there.

Is there any accessible conversion tool which will create a true 16bit/channel raster image from SVG, including gradients? Preferably for Ubuntu.

EDIT: I attach an example. Instead of Color Curves, I use now another color filter, because it is easier to tell how it was parameterized. The effect is similar, though.

Firstly, I use Inkscape 1.0.1 to export https://svgshare.com/s/TQe as an RGB16 PNG to Gimp 2.10. Then I use the filter Brightness/contrast, where I change the contrast to 0.4. The effect:

enter image description here

Some of the subsequent values of the red component, tested with the color picker: 33.9, 38.9, 41.3, scale 0 ... 100. As seen, the accuracy is not even 8 bit.

1

Actually cairo is not rendering the gradients at 16-bit bit per channel depth. There is a open issue about this. See:

Now as this is still just speculation i had a look in cairo source. Yes this is the case. Also verified results in mathematica and photoshop.

So all you get is a 8 bit image in a 16 bit image container. No solution for inkscape, no solution for adobe illstrator, last time i checked no solution for corel, try affinity designer. It is unlikely that any of the common renderers do because svg is a screen renderer by design. Write your own renderer or use a 3D app to render the svg. Since color splines are rather common in 3D apps you might use blender or maya for rendering this. Both apps are also passable if you have shapes but not all really esoteric SVG features.

1

The histogram of your image looks like this:

enter image description here

The histogram of the SVG loaded directly in Gimp or loaded in Inkscape, and exported to PNG and loaded in Gimp are similar. The important features are the gaps and the spikes. When you stretch contrast (and to obtain the image you show above from your SVG you increase contrast a lot) you are in effect widening the gaps:

enter image description here

and the sudden jumps in value create banding.

If you convert to 16-bit in Gimp you still have gaps, so your increase in contrast still creates banding (because the added precision won't fill the gaps (*)).

enter image description here

What you can do in 16-bit mode (or even in 8-bit) is to add a small amount of HSV noise to fill the gaps (you can check the Histogram in real time while you play in the HSV noise dialog, to add as little noise as possible (mostly hue/saturation) to even out the histogram):

enter image description here

Then pushing the contrast doesn't produce banding (but of course makes the added noise more visible).

enter image description here

The method also somehow works in 8-bit, but stretching the contrast as you do will eventually create banding, even if it far less bad that in your in initial attempt.

(*) Technically, the constrast change is a function of the channel values. This means that identical source values yield identical results. So you cannot have more colors in the output than in the inputs. But different input values can yield identical results. So unless your function is the identity you'll always lose colors (but proportionally you lose a lot less colors with 16-bit). If you look at the histogram, a flat histogram in the source image changes into a haircomb, with gaps on one side and spikes on the other.

1
  • Well yes 16 bit color without output dithering is obviously no good. Also avoiding 100% pure colors helps also. – joojaa Jan 25 at 5:53
0

You can do it directly from Inkscape's Export PNG dialog.

Click on Advanced, and select Bit Depth option: RGBA_16

enter image description here

11
  • This is almost what I did when I exported to 16bit PNG, because I exported to RGB_16. But it did not help. I read somewhere on Inkscape forums that it probably just multiplies an 8 bit value. – scriptfoo Jan 24 at 12:26
  • @scriptfoo I just tested an Inkscape generated RGBA_16 PNG on a gradient and there's little if any visible banding. Using a 16bit image doesn't necessarily mean you will get absolutely no banding. It can help reduce it. Sometimes you won't even notice much difference between an 8bit/16bit image. It may also depend on the gradient itself. – Billy Kerr Jan 24 at 12:42
  • It was which version of Inkscape? I use Ubuntu/Inkscape 1.0.1 and I get a red/green banding on a black-to-yellow gradient where intensity is locally multiplied by up to 4. The PNG is recognized by Gimp as 16-bit RGB. – scriptfoo Jan 24 at 12:58
  • @scriptfoo Version 1.0 (4035a4fb49, 2020-05-01). I'm using Windows 10. Can you share the SVG on SVGShare.com? – Billy Kerr Jan 24 at 12:59
  • I added an example with a shared SVG. – scriptfoo Jan 24 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.