added kvec, fix in primitive

This commit is contained in:
Mario Voigt 2021-11-26 13:14:35 +01:00
parent ce54624eea
commit 91ddd0e195
9 changed files with 3741 additions and 5 deletions

Binary file not shown.

View File

@ -0,0 +1,149 @@
******************************************************************************
* K V E C R E A D M E F I L E *
* (License conditions) *
* *
* +++ KK-Software +++ KK-Software +++ KK-Software +++ KK-Software +++ *
*----------------------------------------------------------------------------*
* Author: Karl-Heinz Kuhl, Brunnlohestr. 2, 92637 Weiden, Germany *
*----------------------------------------------------------------------------*
* Voice FAX E-Mail *
* +49 961 6340837 +49 961 61455 support@kvec.de *
******************************************************************************
This program was formerly licensed under the shareware concept.
It is now freeware (2010).
It may be freely distributed, as long as it is complete.
It may not be altered in any way or
distributed by public domain distribution companies without further inquiry.
Furthermore it is not allowed to modify the program or any part of it in any
manner or to disassemble the program.
KVEC is provided "as is", without warranty of any kind or guarantee of
fitness for a particular purpose, either expressed or implied, all of which
are hereby explicitly disclaimed.
The author is not liable for damages of any kind which occur by improper
use of the program by the user, or which were caused by properties of the
operating system under which the program runs.
The newest version of KVEC can be downloaded from my homepage.
Voice: (+49-9602) 9441945 (Mo-Fr, 10-12 Uhr)
Fax/Voice: (+49-9602) 9441946 (24h)
E-Mail: support@kvec.de
WWW: http://www.kvec.de
The KVEC software (Copyright (C) 1997 - 2019 by KK-Software) was developed
by KK-Software with the exception of the JPEG reader with the exception of
the JPEG reader and the zlib compression/decompression routines(see acknowledgements).
A C K N O W L E D G E M E N T S:
--------------------------------
The code for the JPEG reader was taken from the free JPEG library
which is developed by the Independent JPEG Group (IJG).
Copyright (C) 1994-1998, Thomas G. Lane.
The FAX G3/G4 decompression and compression algorithms were derived from parts
of Sam Leffler's free Tiff library.
Copyright (c) 1988-1997 Sam Leffler
Copyright (c) 1991-1997 Silicon Graphics, Inc.
The code for the SVGZ and Flash MX SWF format uses the zlib compression method and was
taken from the free zlib library developed by Jean-loup Gailly and Mark Adler (C) 1995-2002
Many thanks also to (in alphabetical order):
Carsten Gehle (for the implementation on NeXT platforms)
Till Jonas (for help with the AI-Format)
Marcello Krebber (for support of the ART-Format and for OS/2 specific questions)
Peter Neubaecker (for the 'bezier' algorithm and for the 'justifying'
algorithms and for the many discussions).
Matthias Oepen (for the implementation on the HP-UNIX platform)
Joe Czychosz (for the implementation of the thinning algorithm)
==============================================================================
******************************************************************************
* K V E C R E A D M E D A T E I *
* (Lizenz-Bedingungen) *
* *
* +++ KK-Software +++ KK-Software +++ KK-Software +++ KK-Software +++ *
*----------------------------------------------------------------------------*
* Autor: Karl-Heinz Kuhl, Bergstr. 4, 92711 Parkstein, Deutschland *
*----------------------------------------------------------------------------*
* Tel. FAX E-Mail *
* +49 9602 9441945 +49 9602 9441946 support@kvec.de *
******************************************************************************
Dieses Programm wurde früher nach dem Sharewarekonzept vermarktet.
Es ist nun Freewareware (Stand: 2010)
Diese Software Programm darf frei kopiert werden,
sofern sie vollstaendig ist. Sie darf in keiner Form veraendert,
oder ohne Rueckfrage durch Puplic-Domain-Versandtfirmen verschickt werden.
Weiterhin ist es nicht erlaubt, das Programm oder Teile des Programms in
irgendeiner Form zu modifizieren oder zu disassemblieren.
Der Autor uebernimmt keine Haftung fuer Schaeden irgendwelcher Art, die
durch unsachgemaessen Gebrauch des Programms duch den Benutzer verursacht
wurden, oder die von Eigenschaften des Betriebssystems herruehren, auf dem
KVEC laeuft.
Die neueste Version von KVEC steht immer in meiner Homepage zum
Download zur Verfuegung.
Die KVEC Software (Copyright (C) 1997 - 2010 by KK-Software) wurde
ausschliesslich von KK-Software entwickelt, mit Ausnahme des JPEG Readers
(siehe Acknowledgements)
A C K N O W L E D G E M E N T S:
--------------------------------
Der Code fuer den JPEG Reader wurde aus der freien JPEG library (Vers. 6b)
uebernommen, die von der Independent JPEG Group (IJG) entwickelt wird.
Copyright (C) 1994-1998, Thomas G. Lane.
Die FAX G3/G4 Kompressions- und Dekompressions-Algorithmen wurden aus Teilen
der frei verfuegbaren Tiff-Library von Sam Leffler abgeleitet.
Copyright (c) 1988-1997 Sam Leffler
Copyright (c) 1991-1997 Silicon Graphics, Inc.
Der Code fuer die SVGZ und Flash MX SWF Formate benutzt die zlib Kompressions-Methode, die
von der freien zlib Library (entwickelt von Jean-loup Gailly and Mark Adler (C) 1995-2002)
uebernommen wurde.
Vielen Dank ausserdem an (in alphabetischer Reihenfolge):
Carsten Gehle (fuer die Implementierung auf der NeXT Plattform)
Till Jonas (fuer die Hilfe beim AI-Format)
Marcello Krebber (Fuer die Hilfe beim ART-Format und fuer OS/2
spezifische Fragen)
Peter Neubaecker (Fuer den the 'bezier' Algorithmus und fuer den
'justify' Algorithmus und fuer die vielen Diskussionen
und Anregungen).
Matthias Oepen (fuer die Implementierung unter HP-UNIX)
Joe Czychosz (fuer die Implementation des 'thinning' Algorithmus)

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,169 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>KVEC</name>
<id>fablabchemnitz.de.kvec</id>
<param name="tab" type="notebook">
<page name="tab_general" gui-text="KVEC">
<label appearance="header">General Settings</label>
<separator/>
<hbox>
<vbox>
<param name="keeporiginal" type="bool" gui-text="Keep original image on canvas">false</param>
<param name="fittooriginal" type="bool" gui-text="Fit to original dimensions">true</param>
<param name="debug" type="bool" gui-text="Debug output">false</param>
<param name="sysmalloc" type="bool" gui-text="Use system-malloc routines">true</param>
</vbox>
<vbox>
<param name="font" type="bool" gui-text="Generate optimized set of parameters" gui-description="For images with text">false</param>
<param name="text" type="bool" gui-text="Text output">true</param>
<param name="sort" appearance="combo" type="optiongroup" gui-text="Sorting" gui-description="Type of sort order for vectors">
<option value="max">max to min</option>
<option value="min">min to max</option>
<option value="local">local</option>
<option value="color">color</option>
<option value="nosort">nosort</option>
</param>
</vbox>
</hbox>
<separator/>
<hbox>
<vbox>
<label appearance="header">Geometry/Quality</label>
<separator/>
<param name="grit" type="int" min="0" max="256" gui-text="Filter out details smaller than x pixels" gui-description="Details of size smaller than N pixels will be filtered out. 0 disables this option. Values larger than 256 lead to crash.">0</param>
<param name="gapfill" type="int" min="0" max="30" gui-text="Gap fill (jumping)" gui-description="Value must be specified in 10ths of a pixel">0</param>
<param name="centerline" appearance="combo" type="optiongroup" gui-text="Centerlines" gui-description="Generates single lines if linewidth small enough">
<option value="off">off</option>
<option value="mixed">mixed</option>
<option value="lines">lines</option>
</param>
<param name="winding" appearance="combo" type="optiongroup" gui-text="Winding" gui-description="Winding of polygons">
<option value="original">original</option>
<option value="reversed">reversed</option>
<option value="optimized">optimized</option>
</param>
<param name="bezier" type="bool" gui-text="Generate Bezier-curves">false</param>
<param name="errbez" type="int" min="1" max="20" gui-text="Error-Parameter for Bezier-curves">3</param>
<param name="overlapp" type="bool" gui-text="Polygons overlap (1px)" gui-description="Does not work together with High-vectorization resolution">false</param>
<param name="smooth" type="bool" gui-text="Smoothing of polylines">false</param>
<param name="reduce" appearance="combo" type="optiongroup" gui-text="Type of line reducing">
<option value="orthogonal">reduce orthogonal</option>
<option value="all">reduce all</option>
<option value="off">reduce off</option>
</param>
<param name="high_resolution" type="bool" gui-text="High vectorization resolution" gui-description="Default is false. Does not work together with 'Polygons overlap (1px)'">false</param>
<param name="subsampling" type="bool" gui-text="Subsampling" gui-description="If enabled, the output vectors are subsampled by a factor of 2. This will reduce the size of the output file and will also result in smoothing the vectors.">false</param>
<param name="lossless" type="bool" gui-text="Generate lossless image" gui-description="May need enormous memory. Also disabled some other options!">false</param>
<param name="progressive" type="bool" gui-text="Progressive image" gui-description="image is build up from two successive layers (one 'rough' picture without details and one refined picture which contains only details).">false</param>
<param name="progressive_gritfactor" type="int" min="0" max="256" gui-text="Progressive grit factor" gui-description="The first layer has a grit-value multiplied by this">2</param>
<param name="progressive_colorfactor" type="int" min="0" max="30" gui-text="Progressive color factor" gui-description="The first layer has a quantize-value divided by this">2</param>
</vbox>
<vbox>
<label appearance="header">Colors/Styles</label>
<separator/>
<hbox>
<vbox>
<param name="quantize" type="int" min="2" max="99999999" gui-text="Color quantization">32</param>
<param name="delta" type="int" min="0" max="128" gui-text="Delta" gui-description="This is the maximal allowed color difference between the rough and the detail layer.">0</param>
<param name="fill" appearance="combo" type="optiongroup" gui-text="Fill">
<option value="solid">solid</option>
<option value="line">line</option>
<option value="contour">contour</option>
</param>
<param name="lwidth" type="int" min="0" max="1000" gui-text="Line width" gui-description="Value must be specified in 10ths of a pixel">0</param>
<param name="palette" appearance="combo" type="optiongroup" gui-text="Palette">
<option value="optimize">optimize</option>
<option value="fixed">fixed</option>
</param>
<param name="black" type="bool" gui-text="Output-color is always black">false</param>
<param name="color_vectorization" appearance="combo" type="optiongroup" gui-text="color vectorization">
<option value="normal">Normal</option>
<option value="vblack">Only colors with 'darkest' RGB-values</option>
<option value="voblack nwhite">All colors except brightest</option>
<option value="voblack dark">Only darkest and brightest color</option>
</param>
<param name="colspace" appearance="combo" type="optiongroup" gui-text="Color space" gui-description="Colorspace conversion parameters">
<option value="rgb">rgb</option>
<option value="rb">rb</option>
<option value="gb">gb</option>
<option value="gr">gr</option>
<option value="cmyk">cmyk</option>
<option value="cy">cy</option>
<option value="my">my</option>
<option value="mc">mc</option>
</param>
<param name="colsep" appearance="combo" type="optiongroup" gui-text="Color separation" gui-description="Color separation parameters">
<option value="rgb">rgb</option>
<option value="rb">rb</option>
<option value="gb">gb</option>
<option value="gr">gr</option>
<option value="cy">cy</option>
<option value="my">my</option>
<option value="mc">mc</option>
<option value="gg">gg</option>
<option value="bb">bb</option>
<option value="cc">cc</option>
<option value="mm">mm</option>
<option value="yy">yy</option>
</param>
</vbox>
<vbox>
<param name="tcolor_mode" appearance="combo" type="optiongroup" gui-text="Transparency color">
<option value="none">none</option>
<option value="auto">autodetect</option>
<option value="custom">custom color</option>
</param>
<param name="tcolor_custom" type="color" gui-text="Custom transparency color">255</param>
<param name="vcolor_mode" appearance="combo" type="optiongroup" gui-text="Pick out regions with color - mode" gui-description="Use the color picker below">
<option value="none">none</option>
<option value="matching">matching</option>
<option value="not_matching">not_matching</option>
</param>
<param name="vcolor" type="color" gui-text="Region color">255</param>
</vbox>
</hbox>
</vbox>
</hbox>
</page>
<page name="tab_about" gui-text="About">
<label appearance="header">KVEC</label>
<label>Integrates access to KVEC vectorization tool v 4.9 from Karl-Heinz Kuhl (KK-Software). KVEC comes bundled with MightyScape.</label>
<label>2021 / written by Mario Voigt (Stadtfabrikanten e.V. / FabLab Chemnitz)</label>
<spacer/>
<label appearance="header">Online Documentation</label>
<label appearance="url">https://y.stadtfabrikanten.org/kvec</label>
<spacer/>
<label appearance="header">Contributing</label>
<label appearance="url">https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X</label>
<label appearance="url">mailto:mario.voigt@stadtfabrikanten.org</label>
<spacer/>
<label appearance="header">Third Party Modules</label>
<label appearance="url">https://www.kvec.de</label>
<spacer/>
<label appearance="header">MightyScape Extension Collection</label>
<label>This piece of software is part of the MightyScape for Inkscape Extension Collection and is licensed under GNU GPL v3</label>
<label appearance="url">https://y.stadtfabrikanten.org/mightyscape-overview</label>
</page>
<page name="tab_donate" gui-text="Donate">
<label appearance="header">Coffee + Pizza</label>
<label>We are the Stadtfabrikanten, running the FabLab Chemnitz since 2016. A FabLab is an open workshop that gives people access to machines and digital tools like 3D printers, laser cutters and CNC milling machines.</label>
<spacer/>
<label>You like our work and want to support us? You can donate to our non-profit organization by different ways:</label>
<label appearance="url">https://y.stadtfabrikanten.org/donate</label>
<spacer/>
<label>Thanks for using our extension and helping us!</label>
<image>../000_about_fablabchemnitz.svg</image>
</page>
</param>
<effect needs-live-preview="true">
<object-type>all</object-type>
<effects-menu>
<submenu name="FabLab Chemnitz">
<submenu name="Tracing/Images/Edge Detection"/>
</submenu>
</effects-menu>
</effect>
<script>
<command location="inx" interpreter="python">kvec.py</command>
</script>
</inkscape-extension>

View File

@ -0,0 +1,234 @@
#!/usr/bin/env python3
import sys
import inkex
import os
import base64
import urllib.request as urllib
from PIL import Image
from io import BytesIO
from lxml import etree
from inkex import Color
class KVEC (inkex.EffectExtension):
def checkImagePath(self, element):
xlink = element.get('xlink:href')
if xlink and xlink[:5] == 'data:':
# No need, data alread embedded
return
url = urllib.urlparse(xlink)
href = urllib.url2pathname(url.path)
# Primary location always the filename itself.
path = self.absolute_href(href or '')
# Backup directory where we can find the image
if not os.path.isfile(path):
path = element.get('sodipodi:absref', path)
if not os.path.isfile(path):
inkex.errormsg('File not found "{}". Unable to embed image.').format(path)
return
if (os.path.isfile(path)):
return path
def add_arguments(self, pars):
pars.add_argument("--tab")
#General Settings
pars.add_argument("--keeporiginal", type=inkex.Boolean, default=False, help="Keep original image on canvas")
pars.add_argument("--fittooriginal", type=inkex.Boolean, default=False, help="Fit to original dimensions")
pars.add_argument("--debug", type=inkex.Boolean, default=False, help="Enable debug output")
pars.add_argument("--sysmalloc", type=inkex.Boolean, default=True, help="Use system-malloc routines")
pars.add_argument("--text", type=inkex.Boolean, default=True, help="Text output")
pars.add_argument("--font", type=inkex.Boolean, default=True, help="Generate optimized set of parameters")
pars.add_argument("--sort", default="max", help="Type of sort order for vectors")
#Geometry/Quality
pars.add_argument("--grit", type=int, default=0, help="Filter out details smaller than x pixels")
pars.add_argument("--gapfill", type=int, default=0, help="Gap fill (jumping)")
pars.add_argument("--centerline", default="off", help="Generates single lines if linewidth small enough")
pars.add_argument("--bezier", type=inkex.Boolean, default=False, help="Generate Bezier-curves")
pars.add_argument("--errbez", type=int, default=3, help="Error-Parameter for Bezier-curves")
pars.add_argument("--reduce", default="orthogonal", help="Type of line reducing")
pars.add_argument("--overlapp", type=inkex.Boolean, default=False, help="Polygons overlap (1px)")
pars.add_argument("--smooth", type=inkex.Boolean, default=False, help="Smoothing of polylines")
pars.add_argument("--winding", default="original", help="Winding")
pars.add_argument("--high_resolution", type=inkex.Boolean, default=False, help="High vectorization resolution")
pars.add_argument("--subsampling", type=inkex.Boolean, default=False, help="If enabled, the output vectors are subsampled by a factor of 2. This will reduce the size of the output file and will also result in smoothing the vectors")
pars.add_argument("--lossless", type=inkex.Boolean, default=False, help="Generate lossless image")
pars.add_argument("--progressive", type=inkex.Boolean, default=False, help="image is build up from two successive layers (one 'rough' picture without details and one refined picture which contains only details).")
pars.add_argument("--progressive_gritfactor", type=int, default=2, help="The first layer has a grit-value multiplied by this")
pars.add_argument("--progressive_colorfactor", type=int, default=2, help="The first layer has a quantize-value divided by this")
#Colors/Styles
pars.add_argument("--quantize", type=int, default=32, help="Color quantization")
pars.add_argument("--delta", type=int, default=0, help="Delta")
pars.add_argument("--fill", default="solid", help="Fill")
pars.add_argument("--lwidth", type=int, default=0, help="Line width")
pars.add_argument("--black", type=inkex.Boolean, default=False, help="Output-color is always black")
pars.add_argument("--palette", default="optimize", help="Palette")
pars.add_argument("--color_vectorization", default="normal", help="Color vectorization")
pars.add_argument("--colspace", default="rgb", help="Colorspace conversion parameters")
pars.add_argument("--colsep", default="rgb", help="Color separation parameters")
pars.add_argument("--tcolor_mode", default="none", help="Transparency color")
pars.add_argument("--tcolor_custom", type=Color, default=255, help="User-defined transparency color (RGB values)")
pars.add_argument("--vcolor_mode", default="none", help="Pick out regions with color")
pars.add_argument("--vcolor", type=Color, default=255, help="Region color")
def effect(self):
so = self.options
if (so.ids):
for element in self.svg.selected.values():
if element.tag == inkex.addNS('image', 'svg'):
self.path = self.checkImagePath(element) # This also ensures the file exists
if self.path is None: # check if image is embedded or linked
image_string = element.get('{http://www.w3.org/1999/xlink}href')
# find comma position
i = 0
while i < 40:
if image_string[i] == ',':
break
i = i + 1
image = Image.open(BytesIO(base64.b64decode(image_string[i + 1:len(image_string)])))
else:
image = Image.open(self.path)
if element.get('width')[-1].isdigit() is False or element.get('height')[-1].isdigit() is False:
inkex.utils.debug("Image seems to have some weird dimensions in XML structure. Please remove units from width and height attributes at <svg:image>")
return
# Write the embedded or linked image to temporary directory
if os.name == "nt":
exportfile = "kvec.png"
else:
exportfile = "/tmp/kvec.png"
if image.mode != 'RGB':
image = image.convert('RGB')
image.save(exportfile, "png")
#some crash avoidings
if so.lossless is True:
so.color_vectorization = "normal"
so.bezier = False
so.font = False
so.black = False
if so.high_resolution is True:
so.overlapp = False
## Build up command according to your settings from extension GUI
if os.name == "nt":
command = "kvec.exe"
else:
command = "./kvec"
command += " " + exportfile #input
command += " " + exportfile + ".svg" #output
command += " -format svg"
#General Settings
if so.sysmalloc is False: command += " -sysmalloc off"
if so.font is True: command += " -font"
if so.text is False: command += " -text off"
command += " -sort " + so.sort
#Geometry/Quality
if so.grit > 0: command += " -grit " + str(so.grit)
command += " -gapfill " + str(so.gapfill)
command += " -centerline " + so.centerline
command += " -winding " + so.winding
if so.bezier is True: command += " -bezier"
command += " -errbez " + str(so.errbez)
if so.overlapp is True: command += " -overlapp"
if so.smooth is True: command += " -smooth on"
command += " -reduce " + str(so.reduce)
if so.high_resolution is True: command += " -resolution high"
if so.subsampling is True: command += " -subsampling"
if so.lossless is True: command += " -lossless"
if so.progressive is True:
command += " -progressive gritfactor " + str(so.progressive_gritfactor)
command += " -progressive colorfactor " + str(so.progressive_colorfactor)
#Colors/Styles
command += " -quantize " + str(so.quantize)
command += " -delta " + str(so.delta)
command += " -fill " + so.fill
command += " -lwidth " + str(so.lwidth)
command += " -palette " + so.palette
if so.black is True: command += " -black"
if so.color_vectorization != "normal": command += " -" + so.color_vectorization
command += " -colspace " + so.colspace
command += " -colsep " + so.colsep
if so.tcolor_mode == "auto":
command += " -tcolor auto"
elif so.tcolor_mode == "custom":
command += " -tcolor color {} {} {}".format(so.tcolor_custom.red, so.tcolor_custom.green, so.tcolor_custom.blue)
if so.vcolor_mode == "matching":
command += " -vcolor {} {} {}".format(so.vcolor.red, so.vcolor.green, so.vcolor.blue)
elif so.vcolor_mode == "not_matching":
command += " -vcolor {} {} {}".format(-so.vcolor.red, -so.vcolor.green, -so.vcolor.blue)
#some debug stuff
if so.debug is True:
command += " -debug all"
inkex.utils.debug(command)
# Create the vector new SVG file
with os.popen(command, "r") as proc:
result = proc.read()
if so.debug is True: inkex.utils.debug(result)
# proceed if new SVG file was successfully created
doc = None
if os.path.exists(exportfile + ".svg"):
# Delete the temporary png file again because we do not need it anymore
if os.path.exists(exportfile):
os.remove(exportfile)
# new parse the SVG file and insert it as new group into the current document tree
doc = etree.parse(exportfile + ".svg").getroot()
parent = element.getparent()
idx = parent.index(element)
#newGroup = self.document.getroot().add(inkex.Group())
newGroup = inkex.Group()
parent.insert(idx + 1,newGroup)
for child in doc:
newGroup.append(child)
#doc.get('height')
#doc.get('width')
#doc.get('viewBox')
if so.fittooriginal is True: #fitting does not work in all cases so we make it available as option
bbox = newGroup.bounding_box()
newGroup.attrib['transform'] = "matrix({:0.6f}, 0, 0, {:0.6f}, {:0.6f}, {:0.6f})".format(
#float(element.get('width')) / float(doc.get('width')),
#float(element.get('height')) / float(doc.get('height')),
float(element.get('width')) / bbox.width,
float(element.get('height')) / bbox.height,
float(element.get('x')) - (float(element.get('width')) / bbox.width) * bbox.left,
float(element.get('y')) - (float(element.get('height')) / bbox.height) * bbox.top
)
# Delete the temporary svg file
if os.path.exists(exportfile + ".svg"):
try:
os.remove(exportfile + ".svg")
except:
pass
else:
inkex.utils.debug("Error while creating output file! :-( The \"kvec\" executable seems to be missing, has no exec permissions or platform is imcompatible.")
exit(1)
#remove the old image or not
if so.keeporiginal is not True:
element.delete()
else:
inkex.utils.debug("No image found for tracing. Please select an image first.")
if __name__ == '__main__':
KVEC().run()

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,20 @@
[
{
"name": "KVEC",
"id": "fablabchemnitz.de.kvec",
"path": "kvec",
"dependent_extensions": null,
"original_name": "KVEC",
"original_id": "fablabchemnitz.de.kvec",
"license": "GNU GPL v3",
"license_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/LICENSE",
"comment": "",
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/extensions/fablabchemnitz/kvec",
"fork_url": null,
"documentation_url": "https://stadtfabrikanten.org/display/IFM/KVEC",
"inkscape_gallery_url": null,
"main_authors": [
"github.com/vmario89"
]
}
]

View File

@ -71,9 +71,6 @@ class Primitive (inkex.EffectExtension):
def effect(self): def effect(self):
# internal overwrite for scale:
self.options.scale = 1.0
if (self.options.ids): if (self.options.ids):
for node in self.svg.selected.values(): for node in self.svg.selected.values():
if node.tag == inkex.addNS('image', 'svg'): if node.tag == inkex.addNS('image', 'svg'):
@ -146,6 +143,7 @@ class Primitive (inkex.EffectExtension):
# new parse the SVG file and insert it as new group into the current document tree # new parse the SVG file and insert it as new group into the current document tree
doc = etree.parse(exportfile + ".svg").getroot() doc = etree.parse(exportfile + ".svg").getroot()
newGroup = self.document.getroot().add(inkex.Group()) newGroup = self.document.getroot().add(inkex.Group())
newGroup.attrib['transform'] = "matrix({:0.6f}, 0, 0, {:0.6f}, {:0.6f}, {:0.6f})".format( newGroup.attrib['transform'] = "matrix({:0.6f}, 0, 0, {:0.6f}, {:0.6f}, {:0.6f})".format(
float(node.get('width')) / float(doc.get('width')), float(node.get('width')) / float(doc.get('width')),
@ -153,7 +151,9 @@ class Primitive (inkex.EffectExtension):
float(node.get('x')) + x_offset, float(node.get('x')) + x_offset,
float(node.get('y')) + y_offset float(node.get('y')) + y_offset
) )
newGroup.append(doc)
for children in doc:
newGroup.append(children)
# Delete the temporary svg file # Delete the temporary svg file
if os.path.exists(exportfile + ".svg"): if os.path.exists(exportfile + ".svg"):
@ -187,7 +187,7 @@ class Primitive (inkex.EffectExtension):
} }
etree.SubElement(clipPath, 'rect', clipBox) etree.SubElement(clipPath, 'rect', clipBox)
#etree.SubElement(newGroup, 'g', {inkex.addNS('label','inkscape'):'imagetracerjs', 'clip-path':"url(#imagetracerClipPath)"}) #etree.SubElement(newGroup, 'g', {inkex.addNS('label','inkscape'):'imagetracerjs', 'clip-path':"url(#imagetracerClipPath)"})
newGroup.getchildren()[0].set('clip-path','url(#imagetracerClipPath)') newGroup.set('clip-path','url(#imagetracerClipPath)')
else: else:
inkex.utils.debug("No image found for tracing. Please select an image first.") inkex.utils.debug("No image found for tracing. Please select an image first.")