relative paths broken in all extensions

Bug #169094 reported by Tom Davidson
2
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Undecided
Unassigned

Bug Description

Hi,

Inkscape happily opens and displays the image in the attached file, but
when I try to embed the file, it says it can't find it. I suspect it's some
kind of href/namespace issue, but I don't know how to troubleshoot
further.

The full file paths are:

/home/tjd/tmpsvg/embedtest_simple.svg (attached)
/home/tjd/tmpsvg/embedtest001.png (I'll try to attach it later)

When I choose effects->images->embed all images, I get the following error
message:

"No xlink:href or sodipodi:absref attributes found, or they do not point to
an existing file! Unable to embed image.
Sorry we could not locate /tmp/embedtest001.png"

I have looked at the code in $INKSCAPE/extensions/embedimages.py, and I
can't see where it is getting the idea to look in /tmp. As far as I can
tell it should look for the image file in sodipodi:docbase, which according
to the xml browser is in fact /home/tjd/tmpsvg.

The original svg file that triggers this error is generated by a matlab
function plot2svg, written by someone else. If this turns out to be an
error in the writing of the file, I'll report it upstream.

I'm running 0.45.1, using the fc6 rpm provided by RedHat.

Thanks very much! -Tom

Revision history for this message
Tom Davidson (tjd-mit) wrote :
Revision history for this message
Tom Davidson (tjd-mit) wrote :

Originator: YES

File Added: embedtest001.png

Revision history for this message
Tom Davidson (tjd-mit) wrote :

Originator: YES

The extension works fine when called from the command line on the original
file. The problem seems to be that when inkscape writes out the temporary
svg file (attached below) to the temp directory, it changes the
sodipodi:docbase tag (to /tmp, in my case). This breaks relative paths in
xlink:href tags since the external files are not also copied over to /tmp.
I can think of a few fixes, but I have no idea what the ramifications of
any of these might be:

-don't change the sodipodi:docbase tag when writing out the temp file
-rewrite relative paths to absolute paths when saving out the temp file
-copy associated linked files to the temp dir (if using anonymized
filenames, this would also require rewriting the hrefs)

Here is the diff between the two svg files posted below:
$ diff /tmp/ink_ext_GOTW0T ~/tmpsvg/embedtest_simple.svg
19,20c19,20
< sodipodi:docname="ink_ext_GOTW0T"
< sodipodi:docbase="/tmp"
---
> sodipodi:docname="embedtest_simple.svg"
> sodipodi:docbase="/home/tjd/tmpsvg"
51,52c51
< <defs
< id="defs5" />
---
> <defs />

I am unable to test this in SVN because inkscape won't compile on fc6
(gtk+1.2...)

Thanks!
Tom

File Added: ink_ext_GOTW0T

Revision history for this message
Tom Davidson (tjd-mit) wrote :

Originator: YES

When inkscape saves a temporary copy of the svg file for reading by
extensions, it rewrites the sodipodi:docbase attribute. As far as I can
tell, this means that extensions do not have access to the base directory
name, and so can't resolve relative paths.

The reason this doesn't break more things more often is that inkscape by
default adds a sodipodi:absref tag to imported images, which extensions,
such as embedimages.py, default to when they can't resolve the relative
path. I ran into this bug when trying to run this extension on an SVG not
created by inkscape, which only stored the relative path to the file.

I see that there has been a lot of work on getting relative paths to work
as users expecr ( +relative +(path OR paths) brings up 20+ hits in the
bug-tracker). No matter what model of priority of relative and absolute
links is adopted, however, I think the behavior should be consistent
between core code and extensions.

Revision history for this message
Tom Davidson (tjd-mit) wrote :

Originator: YES

I checked out SVN last night and found that this issue has been fixed. I
trapped the 2 temp files with:

 i=1; while true; do cp `inotifywait -e close --format %w%f /tmp` tmp$i;
let "i+=1"; done

One of these is attached below. The sodipodi:docbase tag is no longer
/tmp, so the relative links are correctly built and followed!
File Added: ink_ext_XXXXXX.svg78AW0T

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.