I have an SVG file containing elements defined with a variety of gradients. I need to convert the SVG to a form in which there are no gradients present. I would like to do this in a way in which the effect of the gradient is preserved, but without using actual gradients.
So a linear gradient could be approximated by a series of bands, each with a slightly different shade / hue to the adjacent band. Similar for circular gradients. The effect does not need to be perfect by any means, since I will be displaying these SVG files very small (as icons).
Effectively, this might be achieved by some sort of "simplifier" filter. I am sure this must be possible, but can't find anything so far. Inkscape is amazingly powerful, with a whole host of filters, but can't see anything yet. Any help appreciated!
Flatten gradients in SVG
Re: Flatten gradients in SVG
You could take a look at the Interpolate extension (Extensions -> Generate from path -> Interpolate), if you want to re-create the gradient manually from two objects.
Or, if your gradient is complex with multiple stops, you could make a bitmap copy (Edit -> Create bitmap copy), and then trace that with the desired number of colors by using Path -> Trace Bitmap.
Or, if your gradient is complex with multiple stops, you could make a bitmap copy (Edit -> Create bitmap copy), and then trace that with the desired number of colors by using Path -> Trace Bitmap.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
-
- Posts: 4
- Joined: Tue Apr 05, 2016 6:35 am
Re: Flatten gradients in SVG
Thanks! The second method (converting to bitmap and tracing from that) would seem to suit my purposes just fine. The whole process does seem to mute the colours a little, compared to the original, but I'm sure I can compensate by increasing the saturation before tracing, or something like that.
Thanks again.
Thanks again.
Re: Flatten gradients in SVG
If you just want a visual effect, rather than actually creating a number of separate coloured bands, try the various Poster/Posterise filters under Filters > Image Paint and Draw. They may not get you exactly what you're looking for but, depending on your needs, one of them might get you close enough.
As you're creating icons, I guess that you'll need to export to PNG and possibly convert to another format at that point. In which case you might be better to leave the SVG version with normal gradients and process the images in a bitmap editor afterwards. By reducing the colour depth of the image (in The GIMP use Image > Mode > Indexed) you'll probably be able to not only choose a particular number of colours for the image (and even use a specific palette), but also use dithering to give you a less banded appearance with fewer colours.
As you're creating icons, I guess that you'll need to export to PNG and possibly convert to another format at that point. In which case you might be better to leave the SVG version with normal gradients and process the images in a bitmap editor afterwards. By reducing the colour depth of the image (in The GIMP use Image > Mode > Indexed) you'll probably be able to not only choose a particular number of colours for the image (and even use a specific palette), but also use dithering to give you a less banded appearance with fewer colours.