Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.
/ SplitSVG Public archive

Split a svg file by stroke / fill color

License

Notifications You must be signed in to change notification settings

l3kn/SplitSVG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SplitSvg

When using together with inkscape, export svg images via “File” -> “Save As” and select “Plain SVG” as file type.

Images are processed in five steps

  1. fill and stroke attributes stored in style are extracted and stored directly on the element
  2. Colors are converted to lowercase, named colors (e.g. “red”) are converted to hex colors.
  3. All fill and stroke colors appearing in the image are collected into a list
  4. For each color, a copy of the image is created and all elements with a different color are removed. The image is then saved in a file named color_#abcdef.svg where #abcdef is the color used.
  5. If an element has different fill and stroke colors, when exporting the image for one of them, the other is set to none.

Usage: python3 svg.py input.svg

TODOs

Operations

  • list colors
  • remove color
  • remove everything but one color
  • split colors into layers

Credits

I copied the list of named colors from the Inkscape extension python modules.

About

Split a svg file by stroke / fill color

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages