embed image script fails

Bug #246724 reported by reader4
4
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Undecided
Unassigned

Bug Description

While attempting to embed images in and SVG recently I got this failure:

Traceback (most recent call last):
  File "/usr/share/inkscape/extensions/embedimage.py", line 106, in <module>
    e.affect()
  File "/usr/share/inkscape/extensions/inkex.py", line 154, in affect
    self.effect()
  File "/usr/share/inkscape/extensions/embedimage.py", line 36, in effect
    self.embedAll(self.document)
  File "/usr/share/inkscape/extensions/embedimage.py", line 50, in embedAll
    self.embedImage(node)
  File "/usr/share/inkscape/extensions/embedimage.py", line 54, in embedImage
    if (xlink[:4]!='data'):
TypeError: 'NoneType' object is unsubscriptable

I had embedded several other documents made with the same template already, so I'm not sure if this relates to a specific image or image type, or some other problem.

Revision history for this message
sas (sas-sas) wrote :

This appears to be caused by the absence of an 'xlink:href' attribute on some 'image' element. The SVG specification requires the 'xlink:href' attribute, but I doubt that Inkscape enforces this (on 'image' elements that it didn't create itself), so the script ought to deal gracefully with the absence (e.g, by just ignoring 'image' elements that have no 'xlink:href' attribute).

Revision history for this message
reader4 (cbrace1) wrote :

Exactly the problem... I checked out the XML of my Inkscape file and sure enough, one image was double-tagged, one tag did not have the 'xlink:href' attribute. This would probably be easy for someone who knows python to fix. When looking at the embedimage.py script, it looks like it asks for the 'xlink:href' attribute (line 53), but if it can't find one, it should use the 'sodipodi:absref' attribute instead (line 54). Perhaps when checking for the attribute, it should look to see if it exists first? Sorry I can't be of more help... if I knew anything about coding, I would already have fixed it.

Revision history for this message
sas (sas-sas) wrote :

I've fixed this in SVN revision 19243. If there's no 'xlink:href', it will use 'sodipodi:absref', if possible, and otherwise give an error message and carry on.

If you want to test this, the new version can be downloaded from SourceForge: http://inkscape.svn.sourceforge.net/viewvc/*checkout*/inkscape/inkscape/trunk/share/extensions/embedimage.py (but you will also need the new inkex.py: http://inkscape.svn.sourceforge.net/viewvc/*checkout*/inkscape/inkscape/trunk/share/extensions/inkex.py ).

Changed in inkscape:
status: New → Fix Released
Revision history for this message
reader4 (cbrace1) wrote :

This fixed the issue for me. Thanks!

Revision history for this message
TImothy Baroni (timothy-baroni) wrote :

The error had to do with the struct.py script

I have installed inkscape using MacPorts, so the error was actually in the python25 library file /opt/local/lib/python2.5/struct.py

Line 30 should read:

from struct import *

It used to read:

from struct import _Struct, error

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.