Commit 2f43ea9d authored by Juergen Weigert's avatar Juergen Weigert

added wrapper shell script; moved import inkex after path setting, improved an error message

parent 0ba557f6
...@@ -47,7 +47,6 @@ __version__ = '0.2' # Keep in sync with chain_paths.inx ca line 22 ...@@ -47,7 +47,6 @@ __version__ = '0.2' # Keep in sync with chain_paths.inx ca line 22
__author__ = 'Juergen Weigert <juewei@fabmail.org>' __author__ = 'Juergen Weigert <juewei@fabmail.org>'
import sys, os, re, math, tempfile, subprocess, base64 import sys, os, re, math, tempfile, subprocess, base64
import inkex, simplestyle
try: try:
from PIL import Image from PIL import Image
...@@ -72,7 +71,7 @@ else: # linux ...@@ -72,7 +71,7 @@ else: # linux
sys.path.append('/usr/share/inkscape/extensions') sys.path.append('/usr/share/inkscape/extensions')
# inkscape libraries # inkscape libraries
import inkex import inkex, simplestyle
import cubicsuperpath import cubicsuperpath
inkex.localize() inkex.localize()
...@@ -257,7 +256,7 @@ class TraceCenterline(inkex.Effect): ...@@ -257,7 +256,7 @@ class TraceCenterline(inkex.Effect):
for id, node in self.selected.iteritems(): for id, node in self.selected.iteritems():
if debug: print >>self.tty, "id="+str(id), "tag="+str(node.tag) if debug: print >>self.tty, "id="+str(id), "tag="+str(node.tag)
if node.tag != inkex.addNS('image','svg'): if node.tag != inkex.addNS('image','svg'):
inkex.errormsg(_("Object "+id+" is not an image. Try\n - Object->Ungroup")) inkex.errormsg(_("Object "+id+" is not an image. seen:"+str(node.tag)+" expected:"+inkex.addNS('image','svg')+"\n Try - Object->Ungroup"))
return return
# handle two cases. Embedded and linked images # handle two cases. Embedded and linked images
# <image .. xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAT8AA ..." preserveAspectRatio="none" height="432" width="425" transform="matrix(1,0,-0.52013328,0.85408511,0,0)"/> # <image .. xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAT8AA ..." preserveAspectRatio="none" height="432" width="425" transform="matrix(1,0,-0.52013328,0.85408511,0,0)"/>
......
#!/bin/sh
# shell script wrapper to run an inkscape extension
# as a standaloine tool
image=$1
test -z "$image" && image=./testdata/kringel.png
tmpsvg=/tmp/$$-centerline-trace-wrapper.svg
cat << EOF > $tmpsvg
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="210mm"
height="297mm"
viewBox="0 0 210 297">
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1">
<image
sodipodi:absref="$image"
xlink:href="$image"
width="1456.2667"
height="819.15002"
preserveAspectRatio="none"
id="image4421"
x="-577.12152"
y="-226.81631" />
</g>
</svg>
EOF
python centerline-trace.py --id=image4421 $tmpsvg
#rm $tmpsvg
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment