Difference between revisions of "Save Cleaned SVG"
(New page: = Create Cleaned SVG = Please fix this wiki page if it doesn't fit the standard blueprint template. == Rationale == We're working on a proposal and design for allowing a plugin which sa...) |
|||
Line 60: | Line 60: | ||
http://www.intertwingly.net/blog/2008/02/01/SVG-Tidy | http://www.intertwingly.net/blog/2008/02/01/SVG-Tidy | ||
NOTE: scour (a Python script) has since been developed to automate the cleaning of SVG files. Most of the points on this page have been covered. Suggest using scour as the basis for the Inkscape plugin. | |||
http://codedread.com/scour/ |
Revision as of 03:54, 21 July 2009
Create Cleaned SVG
Please fix this wiki page if it doesn't fit the standard blueprint template.
Rationale
We're working on a proposal and design for allowing a plugin which saves svg data with various things striped and adjusted. Useful for scripting, templating with svg, editing later in a text editor and keeping files small for internet transfer.
Technologies
* Python * python-xml * inkscape plugin svg/python module
Presented Options
The save format would not be totally pre-set or blind but would instead be based on the options selected by the user in a single, simple dialogue much like the pdf export dialogue.
Cleaning Operations
* Specify a limit to the precision of all positional elements. * Clean up XML Elements * Collapse multiple redundent groups * Remove empty tags, such as defs or metadata. * Remove id tags for elements not referenced * Clean up Definitions * Remove unused definitions * Remove duplicate gradient stops * Collapse duplicate gradient definitions * Remove gradients that are only referenced by one other gradient * Clean up CSS * Remove Default values, i.e. opacity: 1; * Remove Not applicable values, i.e. opacity: 0; fill-color: #00000; * Convert RGB colours from RGB(r,g,b) to #RRGGBB format * Convert RGB colours from #RRGGBB to #RGB if possible * Clean up paths * Detect vertical/horizontal lines and replace. * Eliminate empty path segments * Eliminate last segment in a polygon * Collapse straight curves. * Convert absolute path segments to relative ones. * Process Transformations * Process quadratic Bezier curves * Collapse all group based transformations * Convert known properties to element attributes * css to element attributes * Output Standard SVG * Remove inkscape namespace * Remove sodipodi namespace * Remove adobe namespace * Use viewPort instead of document width/height
Tests
Testing of this code can be done automatically with a single good logical test. And should be written first. This involves a single svg document with all the worst noise and each ideal document output from that based on each operation. The test would be simply if the output is reached it passes.
Reference Work
This script has been created in Ruby where some of the ideas have been pulled:
http://www.intertwingly.net/blog/2008/02/01/SVG-Tidy
NOTE: scour (a Python script) has since been developed to automate the cleaning of SVG files. Most of the points on this page have been covered. Suggest using scour as the basis for the Inkscape plugin.