Difference between revisions of "Save Cleaned SVG"

From Inkscape Wiki
Jump to navigation Jump to search
Line 57: Line 57:
== Reference Work ==
== Reference Work ==


* This script has been created in Ruby where some of the ideas have been pulled:
* 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
http://www.intertwingly.net/blog/2008/02/01/SVG-Tidy
Line 65: Line 65:
http://codedread.com/scour/
http://codedread.com/scour/


* Another project: '''islint''', (InkScape lint) It is implemented with an InkScape "Save As" filter.  Some different priorities than the above were assumed, i.e. islint creates a CSS style sheet.  It was written to target web development.  The points above are under review (with the other scripts found here)  An exacting test page would be ''very'' beneficial.
* Another project: '''[./islint islint]''', (InkScape lint) It is implemented with an InkScape "Save As" filter.  Some different priorities than the above were assumed, i.e. islint creates a CSS style sheet.  It was written to target web development.  The points above are under review (with the other scripts found here)  An exacting test page would be ''very'' beneficial.


See: http://islint.sourceforge.net/
See: http://islint.sourceforge.net/


--[[User:Tsingi|Tsingi]] 07:48, 24 September 2009 (UTC)
--[[User:Tsingi|Tsingi]] 07:48, 24 September 2009 (UTC)

Revision as of 12:26, 24 September 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.

http://codedread.com/scour/

  • Another project: [./islint islint], (InkScape lint) It is implemented with an InkScape "Save As" filter. Some different priorities than the above were assumed, i.e. islint creates a CSS style sheet. It was written to target web development. The points above are under review (with the other scripts found here) An exacting test page would be very beneficial.

See: http://islint.sourceforge.net/

--Tsingi 07:48, 24 September 2009 (UTC)