Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
I
inkscape-centerline-trace
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
3dmodeling
inkscape-centerline-trace
Commits
2f43ea9d
Commit
2f43ea9d
authored
May 15, 2016
by
Juergen Weigert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added wrapper shell script; moved import inkex after path setting, improved an error message
parent
0ba557f6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
3 deletions
+40
-3
centerline-trace.py
centerline-trace.py
+2
-3
centerline-trace.sh
centerline-trace.sh
+38
-0
No files found.
centerline-trace.py
View file @
2f43ea9d
...
@@ -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)"/>
...
...
centerline-trace.sh
0 → 100644
View file @
2f43ea9d
#!/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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment