summaryrefslogtreecommitdiffstats
path: root/share/extensions/embedimage.py
diff options
context:
space:
mode:
authorStephen Silver <sasilver@yahoo.com>2008-07-09 17:51:46 +0000
committersasilver <sasilver@users.sourceforge.net>2008-07-09 17:51:46 +0000
commitac7b54155c986ec5a390174a5f7c4af732fc4bdc (patch)
treecd1b73b233815727d2e0d3d631e446eb981d2195 /share/extensions/embedimage.py
parentremove tolerance from tool prefs now that it's on the controls bar (diff)
downloadinkscape-ac7b54155c986ec5a390174a5f7c4af732fc4bdc.tar.gz
inkscape-ac7b54155c986ec5a390174a5f7c4af732fc4bdc.zip
Some fixes for the Embed All Images extension:
1) Cope with missing xlink:href. (Fixes bug 246724.) 2) Don't ignore images with filenames that begin with "data". 3) Remove an unused line. 4) Suppress part of an error message in cases where it makes no sense. (bzr r6250)
Diffstat (limited to 'share/extensions/embedimage.py')
-rw-r--r--share/extensions/embedimage.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/share/extensions/embedimage.py b/share/extensions/embedimage.py
index ab903a18e..93472b325 100644
--- a/share/extensions/embedimage.py
+++ b/share/extensions/embedimage.py
@@ -53,10 +53,9 @@ class Embedder(inkex.Effect):
def embedImage(self, node):
xlink = node.get(inkex.addNS('href','xlink'))
- if (xlink[:4]!='data'):
+ if xlink is None or xlink[:5] != 'data:':
absref=node.get(inkex.addNS('absref','sodipodi'))
href=xlink
- svg=self.document.getroot().xpath('/svg:svg', namespaces=inkex.NSS)[0]
path=''
#path selection strategy:
# 1. href if absolute
@@ -70,9 +69,12 @@ class Embedder(inkex.Effect):
if (not os.path.isfile(path)):
if (absref != None):
path=absref
+
if (not os.path.isfile(path)):
inkex.errormsg(_('No xlink:href or sodipodi:absref attributes found, or they do not point to an existing file! Unable to embed image.'))
-
+ if path:
+ inkex.errormsg(_("Sorry we could not locate %s") % path)
+
if (os.path.isfile(path)):
file = open(path,"rb").read()
embed=True
@@ -97,8 +99,6 @@ class Embedder(inkex.Effect):
del node.attrib[inkex.addNS('absref',u'sodipodi')]
else:
inkex.errormsg(_("%s is not of type image/png, image/jpeg, image/bmp, image/gif, image/tiff, or image/x-icon") % path)
- else:
- inkex.errormsg(_("Sorry we could not locate %s") % path)
if __name__ == '__main__':
e = Embedder()