Flatten gradients in SVG

Post questions on how to use or achieve an effect in Inkscape.
drmrbrewer
Posts: 4
Joined: Tue Apr 05, 2016 6:35 am

Flatten gradients in SVG

Postby drmrbrewer » Tue Jun 14, 2016 7:15 am

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!

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Flatten gradients in SVG

Postby Moini » Tue Jun 14, 2016 9:02 am

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.
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)

drmrbrewer
Posts: 4
Joined: Tue Apr 05, 2016 6:35 am

Re: Flatten gradients in SVG

Postby drmrbrewer » Tue Jun 14, 2016 6:04 pm

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.

User avatar
Xav
Posts: 1209
Joined: Fri May 08, 2009 1:18 am
Location: UK
Contact:

Re: Flatten gradients in SVG

Postby Xav » Tue Jun 14, 2016 7:23 pm

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.
Co-creator of The Greys and Monsters, Inked - Inkscape drawn webcomics
Web SiteFacebookTwitter


Return to “Help with using Inkscape”