Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot load .svg to label to images
#3
(12-26-2023, 04:38 AM)Someone Wrote: Hello, i am trying to add an .svg label to images using Python-fu, but getting an unhelpful error code when trying to load the .svg

My console text:

➤> pdb.gimp_path_import(image, "label.svg", TRUE, FALSE)

the error:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
RuntimeError: execution error

I am guessing this is a path problem.  New to this stuff, any tips would be appreciated, thanks!

"label.svg" doesn't tell where the file is, since there is no path component. So this is normally interpreted as "in the current working directory", which is, depending on how Gimp was started: 
  • the user's home directory on Linux (if started from a desktop icon)
  • the CWD of the terminal (if started by entering gimp in a Linux terminal),
  • (IIRC) the directory of the .EXE (on Windows)
You can retrieve this information using os.getcwd() (you of course have to import os).

In practice, depending on source:
  • If the file can be anywhere, set up a parameter with a PF_FILENAME type to have a file selector,
  • If the file is somewhere in the Gimp profile you can find the location of the profile in gimp.directory
  • If the file is somewhere in specific user directories, you can have the location of such directories using gimp.user_directory(n) (starting with n=0: Desktop, Documents, Downloads, Music, Pictures, Public, Templates, Videos)
And use os.path.join() to create complete paths: os.path.join(gimp.user_directory(4),'SVG','label.svg')
Reply


Messages In This Thread
Cannot load .svg to label to images - by Someone - 12-26-2023, 04:38 AM
RE: Cannot load .svg to label to images - by Ofnuts - 12-26-2023, 10:11 AM

Forum Jump: