Open ernierasta opened 2 years ago
I will add, that it would of course be possible to add configuration option for user to decide, but I am not sure if there is situation, when absolute paths are useful.
~~Also, I had just realized, that my fix for static images will not fix anything in many cases. Problem is, that if we use embedded image generated component will contain:
xlink:href
containing data: image/png, ...
- but data represents template image, not image, that is defined in csv.
There will also be sodipodi:absref
containing filenamefromcsv.png
- which will also do not work, as image maybe on different path.So while looking at image linking I think I should fix those too.~~
Sometimes it took me long time to wake-up at the morning :). Wrong ID caused my confusion.
I am not sure how it is supposed to work. I could never figure out a way to get a path to where the SVG file exists. You need that to get correct relative paths to the images.
For the CSV file you need the relative path from wherever the current directory for Inkscape is. That depends on how you launch it and for instance what current directory you have in a shell if you launch it from a terminal? Before the folder change, back in previous versions when you needed to input the absolute path manually, I used to launch Inkscape from a terminal in the directory where my CSV file was, so I could use just the filename, but that trick no longer works and that never worked anyway when for instance launching Inkscape from a start-menu or desktop shortcut.
There is already a list of paths to search for relative CSV files, so you can for instance put the file in your Documents folder and just use the filename.
There are now inkex functions to get svg path, so no problem. Yes, it was very hard in the past.
In my opinion csv should be relative to svg file path and I think many would expect that. So it is easy now. While someone could use Documents and other folders, it may be bit impractical IMHO.
I know. If I recall it correctly, when I was writing experimental implementation I had just added path relative to svg there and it worked as expected.
I made an attempt at this a while ago, but inkex just returns /tmp or some equally useless paths. Could not figure out a way to get the needed path to the SVG. Is there some function I overlook? Seems just as bad as it was in the past.
Hi Pelle, I am analyzing how countersheetextension works with paths I am not very happy with current state.
Facts:
1) We can not use relative paths in extension configuration. Datafile (csv) and image directory will not work as expected. 2) All generated images have absolute paths in
sodipodi:absref
andxlink:href
. Inkscape 1.1 creates onlyxlink:href
attribute and sets there absolute path which is changed to relative after saving svg file.In current versions Inkscape prefer relative paths. I think they get rid of
sodipodi:absref
and one of the main reasons was that users complained about personal data leaks (usually you know user home dir location, OS language, etc).So in current state files generated by extension have mixed paths. All linked images in template are defined by relative path and all generated components have absolute paths. I would like to unify it, so will use only relative paths and get rid of
sodipodi:absref
(which seems to not be created ifxlink:href
is relative path anyway).What is your opinion on the topic?
What I would propose:
Ad 1): This problem is related to fact, we switched to
type="folder"
, which is great, as it allows users to click to point to path. But as negative side-effect it always returns absolute path, so if enter there:cards.csv
orimages
it will return absolute path to extensions directory + filename. On Linux:/home/user/.config/inkscape/extensions/cards.csv
My plan is to add invisible path element oftype="folder"
to get correct path to extension directory in python script and then we can get correct relative path entered by user.Lets say that this additional path is named
extensionsdir
:relativepath = imagedir.replace(extensionsdir, "")
You may argue that we can get script path by standard python functions - we can't, believe me. :smile:
Why this useful to support that? IMHO it is much quicker, to enter f.e.:
cards.csv
andimages
in, compared to clicking through file explorer to point to csv and image files, which will be usually very "close" to svg file.Ad 2) I would like to generate only relative paths, so only
xlink:href
is used and always contains relative path to image file.