summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2018-05-13 14:35:04 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2018-05-13 14:35:04 +0000
commite6616e3a2aa1ffa83fe173e2180849d1ca14a49d (patch)
treee7b2d1392abea351244452fba0356d72509b900f /share
parentAdd preview for numeric OpenType features. (diff)
downloadinkscape-e6616e3a2aa1ffa83fe173e2180849d1ca14a49d.tar.gz
inkscape-e6616e3a2aa1ffa83fe173e2180849d1ca14a49d.zip
Fix bug embeding SVG as PNG
Diffstat (limited to 'share')
-rwxr-xr-xshare/extensions/extractimage.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/share/extensions/extractimage.py b/share/extensions/extractimage.py
index 031a01560..b30a326a7 100755
--- a/share/extensions/extractimage.py
+++ b/share/extensions/extractimage.py
@@ -21,6 +21,7 @@ import base64
import os
# local library
import inkex
+import imghdr
class MyEffect(inkex.Effect):
def __init__(self):
@@ -32,12 +33,13 @@ class MyEffect(inkex.Effect):
help="")
def effect(self):
mimesubext={
- 'png' :'.png',
- 'bmp' :'.bmp',
- 'jpeg':'.jpg',
- 'jpg' :'.jpg', #bogus mime
- 'icon':'.ico',
- 'gif' :'.gif'
+ 'png' : '.png',
+ 'svg+xml' : '.svg',
+ 'bmp' : '.bmp',
+ 'jpeg' : '.jpg',
+ 'jpg' : '.jpg', #bogus mime
+ 'icon' : '.ico',
+ 'gif' : '.gif'
}
# exbed the first embedded image
@@ -63,11 +65,14 @@ class MyEffect(inkex.Effect):
path = os.path.join(os.environ['USERPROFILE'],path)
else:
path = os.path.join(os.path.expanduser("~"),path)
- inkex.errormsg(_('Image extracted to: %s') % path)
break
#save
data = base64.decodestring(xlink[comma:])
open(path,'wb').write(data)
+ if fileext == '.png' and imghdr.what(path) != 'png':
+ os.rename(path, path.replace(".png",".svg"))
+ path.replace(".png",".svg");
+ inkex.errormsg(_('Image extracted to: %s') % path)
node.set(inkex.addNS('href','xlink'),os.path.realpath(path)) #absolute for making in-mem cycles work
else:
inkex.errormsg(_('Unable to find image data.'))