Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

If I create a gradient between two similar colours in Inkscape and export it to a png it looks something like this:
enter image description here
If you look closely you can see rings.
If I create a gradient in GIMP, there's the option to use dithering to prevent such rings or lines.
How do I convert my svg to a png using dithering for gradients?

share|improve this question
    
Can you link your problematic SVG file? –  zetah Nov 19 '11 at 13:07
    
Here you go: pastebin.com/download.php?i=0hYYxEGV Just rename the file to end on .svg –  user142 Nov 19 '11 at 13:18
    
Well, I don't know how you expect dither to work, but usually you dither hires signal to lores, while you seem to expect to dither lores, which can't work of course. If you want to dither in Gimp change image color mode, there is dithering option, but you wont make anything of it on your sample. I'm sure there is DSP process which will let you do what you want, but I don't know. Why don't you use Gimp's gradient feature? Here is you SVG image converted to PNG using Gimp: i.imgur.com/EwaBl.png –  zetah Nov 19 '11 at 13:43
    
The posted image just shows the problem. The actual image I want to convert is a lot more complex and it would take some time to recreate it in GIMP and it would have some major drawbacks (after all there is a reason people are using vector graphics). Thanks for your help, anyway. –  user142 Nov 19 '11 at 14:01

3 Answers 3

Try Gimp "Spread" filter (Filter > Noise > Spread) with 40px value for your sample

I found it in a comment in Inkscape bug tracker and it produces great results IMHO

share|improve this answer
    
This works only if you have one single gradient (and then I could just create it in GIMP without Inkscape). As soon as you have a more complex image (with sharp edges for example) it kind of blurs the whole image. –  user142 Nov 19 '11 at 16:41
    
On image you posted it works great, or? You can select regions of interest in Gimp and apply filter only on part of image, but you can't expect from me to imagine your original design or filter that will automagically correct everything - it does not exist –  zetah Nov 19 '11 at 16:56
    
Just because you don't know how to solve my problem properly (btw you mentioned the idea to use Illustrator which is the best solution so far), it does not mean a solution does not exist. You posted a link to a patch that would probably fix the problem in Inkscape, so a solution does exist. It just has to be implemented in Inkscape. Maybe it is already implemented in an other program but you and I don't know which one so let's wait for someone who does. Cheers –  user142 Nov 19 '11 at 18:53
    
You have some attitude - I was trying to help and provide some info to potentially interested users, not to necessarily solve your problems. First, your question is misleading, because as already said dithering is done other way around - not like you assumed. Then, if you focus on image/file you provided as example, and anyone can test that result from Gimp spread filter is best you can get - no other tool or wisdom can apply noise filtering with different parameters and only on regions where different gradients exist - you'll have to do selections and filter parameters by hand if it's worth. –  zetah Nov 20 '11 at 2:44
    
Also Illustrator, CorelDraw or compiling Inkscape with patch from source, are solutions for your future and not for your current problem, as SVG file which you created with Inkscape is already with problematic gradient. –  zetah Nov 20 '11 at 2:45

Well, I don't know how you expect dither to work, but usually you dither hires signal to lores, while you seem to expect to dither lores, which can't work of course.

Yeah, no.

Dithering in gradients is not done for reasons of resolution, but for reasons of bit-rate. You get banding effects because InkScape's export to PNG incorrectly rounds down the (floating-point) RGB values of the interpolated gradient to 8-bit values (256 steps).

This results in a very annoying and noticeable type of banding noise (as opposed to aliasing noise which would be the case if we were talking about resolution). Applying dither is a form of noise-shaping, which doesn't reduce the noise but spreads it out in spatial domain so it doesn't correlate into noticeable shapes any more (I'll spare you the signal theory).

Your "solution" of applying the spread noise filter in GIMP really is no better than someone encountering jagged edges in line-art, asking directly about the anti-aliasing option, and telling them to apply a Gaussian blur!

Consider: A photo, reduced to 4 colours with no dither, and a spread noise filter applied afterwards. A photo reduced to 4 colours with dither. Which one looks better?

How do you "hide" jagged edges -> blur. How do you solve jagged edges -> anti aliasing when rendering. How do you "hide" banding in gradients -> spread noise, etc (there's better tricks but you always end up throwing away fidelity). How do you SOLVE banding in gradients -> apply dithering during render!

So yeah, I can actually understand the attitude, when asking how to solve a problem, being told to sort of brush it under the carpet. That's not a solution for a serious graphics designer.

I'm currently wrestling with the same problem. The question also was perfectly clear, I know because I arrived at this page looking for the same answer. What I'm trying to do is applying a slight layer of noise with a filter or extension in InkScape, which is hopefully applied before rendering, bumping the rounding error around a bit, resulting in a not-optimal but better-than-nothing poor man's noise-shaper. But at least it'll preserve the detail that doesn't require dither :)

share|improve this answer

Please don't consider this as answer. I'm writing it as answer as writing comment is limiting

This seems to be known problem with Inkscape. Quick googling showed to me:

  1. Patching source (0.48.0), then compiling Inkscape

  2. Applying some filter (by editing /usr/share/inkscape/filters/filters.svg) like posted here or here, which is BTW useless on your sample

  3. Additionally search the web for resolving Inkscape gradient banding problem

  4. Try other tool if possible

I'll just add that last step is my suggestion and while you could try Xara or sK1 it seems to me that only commercial tools (CorelDraw, Illustrator...) offer flawless features, which has to be indeed considered when doing serious work, as you won't like things like this happen after rendering

Cheers

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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