Suppose that a gimp (PyGIMP) plugin needs access to some arbitrary image files distributed with the plug-in. Given that the set can be installed by the user anywhere, is there a way for the plug-in itself to determine its own installation path to use as a path prefix for those resources (e.g., images)?? I have tried searching the pdb, but I must be missing something.
Asked
Active
Viewed 129 times
1 Answers
1
Like in all python code, you can find your code origin using os.path.realpath(__file__)
, but since Gimp calls the script by its full path you can also use os.path.abspath(sys.argv[0])
.
However:
- There are several variables that contain various directory locations:
gimp.directory
,gimp.data_directory
,gimp.locale_directory
,gimp.plug_in_directory
. - If the script is installed at the system level, resources are best put in
os.path.join(gimp.data_directory,'scripts')

xenoid
- 8,396
- 3
- 23
- 49