#!/usr/bin/env python # -*- coding: utf-8 -*- # Scour # # Copyright 2009 Jeff Schiller # # This file is part of Scour, http://www.codedread.com/scour/ # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Notes: # rubys' path-crunching ideas here: http://intertwingly.net/code/svgtidy/spec.rb # (and implemented here: http://intertwingly.net/code/svgtidy/svgtidy.rb ) # Yet more ideas here: http://wiki.inkscape.org/wiki/index.php/Save_Cleaned_SVG # TODO: Adapt this script into an Inkscape python plugin # # * Clean up Definitions # * Collapse duplicate gradient definitions # * Clean up paths # * Eliminate last segment in a polygon # * Process Transformations # * Process quadratic Bezier curves # * Collapse all group based transformations # Suggestion from Richard Hutch: # * Put id attributes first in the serialization (or make the d attribute last) # This would require my own serialization fo the DOM objects (not impossible) # Next Up: # + fix bug with consecutive path coordinates not being translated properly to relative commands # + convert straight curves to lines # + eliminate last segment in a polygon # - provide command-line option to disable raster-to-base64 conversion # - remove id if it matches the Inkscape-style of IDs (also provide a switch to disable this) # - convert polygons/polylines to path? (actually the change in semantics may not be worth the marginal savings) # - prevent elements from being stripped if they are referenced in a