Fix Bug 503750: Update inkscape extension to include new --enable-viewboxing option
This commit is contained in:
parent
ed1c522caf
commit
6230682a01
4 changed files with 19 additions and 16 deletions
|
|
@ -37,10 +37,13 @@ class ScourInkscape (inkex.Effect):
|
||||||
self.OptionParser.add_option("--indent",
|
self.OptionParser.add_option("--indent",
|
||||||
action="store", type="string", dest="indent_type", default="space",
|
action="store", type="string", dest="indent_type", default="space",
|
||||||
help="indentation of the output: none, space, tab (default: %default)")
|
help="indentation of the output: none, space, tab (default: %default)")
|
||||||
|
self.OptionParser.add_option("--enable-viewboxing", type="inkbool",
|
||||||
|
action="store", dest="enable_viewboxing", default=False,
|
||||||
|
help="changes document width/height to 100%/100% and creates viewbox coordinates")
|
||||||
|
|
||||||
|
|
||||||
def effect(self):
|
def effect(self):
|
||||||
input = file(sys.argv[11], "r")
|
input = file(sys.argv[12], "r")
|
||||||
sys.stdout.write(scourString(input.read(), self.options).encode("UTF-8"))
|
sys.stdout.write(scourString(input.read(), self.options).encode("UTF-8"))
|
||||||
input.close()
|
input.close()
|
||||||
sys.stdout.close()
|
sys.stdout.close()
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
<param name="enable-id-stripping" type="boolean" _gui-text="Enable id stripping">false</param>
|
<param name="enable-id-stripping" type="boolean" _gui-text="Enable id stripping">false</param>
|
||||||
<param name="embed-rasters" type="boolean" _gui-text="Embed rasters">true</param>
|
<param name="embed-rasters" type="boolean" _gui-text="Embed rasters">true</param>
|
||||||
<param name="keep-editor-data" type="boolean" _gui-text="Keep editor data">false</param>
|
<param name="keep-editor-data" type="boolean" _gui-text="Keep editor data">false</param>
|
||||||
|
<param name="enable-viewboxing" type="boolean" _gui-text="Enable viewboxing">false</param>
|
||||||
<param name="strip-xml-prolog" type="boolean" _gui-text="Strip xml prolog">false</param>
|
<param name="strip-xml-prolog" type="boolean" _gui-text="Strip xml prolog">false</param>
|
||||||
<param name="set-precision" type="int" _gui-text="Set precision">5</param>
|
<param name="set-precision" type="int" _gui-text="Set precision">5</param>
|
||||||
<param name="indent" type="enum" _gui-text="Indent">
|
<param name="indent" type="enum" _gui-text="Indent">
|
||||||
|
|
@ -29,6 +30,7 @@
|
||||||
* Enable id stripping: remove all un-referenced ID attributes.
|
* Enable id stripping: remove all un-referenced ID attributes.
|
||||||
* Embed rasters: embed rasters as base64-encoded data.
|
* Embed rasters: embed rasters as base64-encoded data.
|
||||||
* Keep editor data: don't remove Inkscape, Sodipodi or Adobe Illustrator elements and attributes.
|
* Keep editor data: don't remove Inkscape, Sodipodi or Adobe Illustrator elements and attributes.
|
||||||
|
* Enable viewboxing: size image to 100%/100% and introduce a viewBox
|
||||||
* Strip xml prolog: don't output the xml prolog.
|
* Strip xml prolog: don't output the xml prolog.
|
||||||
* Set precision: set number of significant digits (default: 5).
|
* Set precision: set number of significant digits (default: 5).
|
||||||
* Indent: indentation of the output: none, space, tab (default: space).</_param>
|
* Indent: indentation of the output: none, space, tab (default: space).</_param>
|
||||||
|
|
|
||||||
20
scour.py
20
scour.py
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
# Scour
|
# Scour
|
||||||
#
|
#
|
||||||
# Copyright 2009 Jeff Schiller
|
# Copyright 2010 Jeff Schiller
|
||||||
#
|
#
|
||||||
# This file is part of Scour, http://www.codedread.com/scour/
|
# This file is part of Scour, http://www.codedread.com/scour/
|
||||||
#
|
#
|
||||||
|
|
@ -73,7 +73,7 @@ except ImportError:
|
||||||
|
|
||||||
APP = 'scour'
|
APP = 'scour'
|
||||||
VER = '0.23'
|
VER = '0.23'
|
||||||
COPYRIGHT = 'Copyright Jeff Schiller, 2009'
|
COPYRIGHT = 'Copyright Jeff Schiller, 2010'
|
||||||
|
|
||||||
NS = { 'SVG': 'http://www.w3.org/2000/svg',
|
NS = { 'SVG': 'http://www.w3.org/2000/svg',
|
||||||
'XLINK': 'http://www.w3.org/1999/xlink',
|
'XLINK': 'http://www.w3.org/1999/xlink',
|
||||||
|
|
@ -510,18 +510,16 @@ def removeUnusedDefs(doc, defElem, elemsToRemove=None):
|
||||||
|
|
||||||
keepTags = ['font', 'style', 'metadata', 'script', 'title', 'desc']
|
keepTags = ['font', 'style', 'metadata', 'script', 'title', 'desc']
|
||||||
for elem in defElem.childNodes:
|
for elem in defElem.childNodes:
|
||||||
|
# only look at it if an element and not referenced anywhere else
|
||||||
|
if elem.nodeType == 1 and (elem.getAttribute('id') == '' or \
|
||||||
|
(not elem.getAttribute('id') in referencedIDs)):
|
||||||
|
|
||||||
# we only inspect the children of a group in a defs if the group
|
# we only inspect the children of a group in a defs if the group
|
||||||
# is not referenced anywhere else
|
# is not referenced anywhere else
|
||||||
if elem.nodeName == 'g' and elem.namespaceURI == NS['SVG'] and \
|
if elem.nodeName == 'g' and elem.namespaceURI == NS['SVG']:
|
||||||
not elem.getAttribute('id') in referencedIDs:
|
|
||||||
elemsToRemove = removeUnusedDefs(doc, elem, elemsToRemove)
|
elemsToRemove = removeUnusedDefs(doc, elem, elemsToRemove)
|
||||||
continue
|
# we only remove if it is not one of our tags we always keep (see above)
|
||||||
|
elif not elem.nodeName in keepTags:
|
||||||
# we only remove if it is an element with a blank id and it is
|
|
||||||
# a direct child of the defs
|
|
||||||
if elem.nodeType == 1 and (elem.getAttribute('id') == '' or \
|
|
||||||
(not elem.getAttribute('id') in referencedIDs)) and \
|
|
||||||
not elem.nodeName in keepTags:
|
|
||||||
elemsToRemove.append(elem)
|
elemsToRemove.append(elem)
|
||||||
return elemsToRemove
|
return elemsToRemove
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
# Test Harness for Scour
|
# Test Harness for Scour
|
||||||
#
|
#
|
||||||
# Copyright 2009 Jeff Schiller
|
# Copyright 2010 Jeff Schiller
|
||||||
#
|
#
|
||||||
# This file is part of Scour, http://www.codedread.com/scour/
|
# This file is part of Scour, http://www.codedread.com/scour/
|
||||||
#
|
#
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue