Posts: 74
Threads: 20
Joined: Feb 2024
Reputation:
0
Operating system(s):
- Windows Vista or 7, 8, 10 (64-bit)
Gimp version: 2.10
Hi
When I call an existing plugin installed in my own plugin, how can I specify the "current folder", which is the folder the gimp file is in?
See "???"
pdb.python_fu_ofn_export_layers(timg, "???", "{numUp0}.png", "-", 0)
Posts: 6,349
Threads: 274
Joined: Oct 2016
Reputation:
565
Operating system(s):
Gimp version: 2.10
If you mean the folder form the image, then:
- Given timg
- timg.filename is the complete path to the file the image was loaded from
- os.path.dirname(some_path) extracts the parent directory in a path
- so what you want is in os.path.dirname(timg.filename)
So you code looks like:
Code:
import os # somewhere at the top of your file, otherwise os.path.dirname won't be resolved
pdb.python_fu_ofn_export_layers(timg, os.path.dirname(timg.filename)), "{numUp0}.png", "-", 0)
Posts: 74
Threads: 20
Joined: Feb 2024
Reputation:
0
Operating system(s):
- Windows Vista or 7, 8, 10 (64-bit)
Gimp version: 2.10
(02-28-2024, 11:08 PM)Ofnuts Wrote: If you mean the folder form the image, then:
- Given timg
- timg.filename is the complete path to the file the image was loaded from
- os.path.dirname(some_path) extracts the parent directory in a path
- so what you want is in os.path.dirname(timg.filename)
So you code looks like:
Code:
import os # somewhere at the top of your file, otherwise os.path.dirname won't be resolved
pdb.python_fu_ofn_export_layers(timg, os.path.dirname(timg.filename)), "{numUp0}.png", "-", 0)
I have a working small plugin.
At the top is this
Code:
from gimpfu import*
When adding
above or below this line and adding the line you gave me, the plugin does not appear anymore in GIMP.
If I remove the line, it appears again
Posts: 6,349
Threads: 274
Joined: Oct 2016
Reputation:
565
Operating system(s):
Gimp version: 2.10
(02-29-2024, 12:22 AM)gimpygirl Wrote: (02-28-2024, 11:08 PM)Ofnuts Wrote: If you mean the folder form the image, then:
- Given timg
- timg.filename is the complete path to the file the image was loaded from
- os.path.dirname(some_path) extracts the parent directory in a path
- so what you want is in os.path.dirname(timg.filename)
So you code looks like:
Code:
import os # somewhere at the top of your file, otherwise os.path.dirname won't be resolved
pdb.python_fu_ofn_export_layers(timg, os.path.dirname(timg.filename)), "{numUp0}.png", "-", 0)
I have a working small plugin.
At the top is this
Code:
from gimpfu import*
When adding
above or below this line and adding the line you gave me, the plugin does not appear anymore in GIMP.
If I remove the line, it appears again
Oops, extra parenthesis after timg.filename, try:
Code:
pdb.python_fu_ofn_export_layers(timg, os.path.dirname(timg.filename), "{numUp0}.png", "-", 0)
Posts: 74
Threads: 20
Joined: Feb 2024
Reputation:
0
Operating system(s):
- Windows Vista or 7, 8, 10 (64-bit)
Gimp version: 2.10
That makes me wonder something new
IF there is a syntax error, there is not anything reported by GIMP?
Can this be seen anywhere?
So my plugin just didn't appear anymore but I had no idea why.
Posts: 6,349
Threads: 274
Joined: Oct 2016
Reputation:
565
Operating system(s):
Gimp version: 2.10
Yes, in the Gimp standard error stream. But on Windows it is typically hidden (but I think you can get at it if you start Gimp with gimp-console.exe).
Otherwise:
- You can catch the worst blunders (unbalanced parentheses, indentation...) by trying to run the code in a command prompt (it should fail, but not elicit syntax errors)
- You bracket the code in a try/except block, and display the Python error in a Gimp message.
See examples in most of my scripts....
Posts: 74
Threads: 20
Joined: Feb 2024
Reputation:
0
Operating system(s):
- Windows Vista or 7, 8, 10 (64-bit)
Gimp version: 2.10
02-29-2024, 06:33 PM
(This post was last modified: 02-29-2024, 06:35 PM by gimpygirl.)
(02-29-2024, 12:07 PM)Ofnuts Wrote: Yes, in the Gimp standard error stream. But on Windows it is typically hidden (but I think you can get at it if you start Gimp with gimp-console.exe).
Otherwise:
- You can catch the worst blunders (unbalanced parentheses, indentation...) by trying to run the code in a command prompt (it should fail, but not elicit syntax errors)
- You bracket the code in a try/except block, and display the Python error in a Gimp message.
See examples in most of my scripts....
How to run code in command prompt?
I found the gimp-console.exe but it doesn't show gimp, only a bunch of errors. Should it show GIMP and the console at the same time, right? Here is does not show gimp
What to do to remove the errors?
Code:
GEGL-Message: 19:30:45.047: Module 'F:\Programma\GIMP 2\lib\gegl-0.4\exr-save.dll' load error: 'F:\Programma\GIMP 2\lib\gegl-0.4\exr-save.dll': Kan opgegeven module niet vinden.
GEGL-Message: 19:30:45.047: Module 'F:\Programma\GIMP 2\lib\gegl-0.4\exr-load.dll' load error: 'F:\Programma\GIMP 2\lib\gegl-0.4\exr-load.dll': Kan opgegeven module niet vinden.
Skipping duplicate plug-in: 'F:\Programma\GIMP 2\lib\gimp\2.0\plug-ins\ofn-export-layers\ofn-export-layers.html'
Skipping duplicate plug-in: 'F:\Programma\GIMP 2\lib\gimp\2.0\plug-ins\ofn-guillotine-layer\ofn-guillotine-layer.html'
GIMP-Fout: Unable to run plug-in "ofn-tiles.html"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-tiles.html)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "ofn-preset-guides.log"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-preset-guides.log)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "ofn-preset-guides.ini"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-preset-guides.ini)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "ofn-preset-guides.html"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-preset-guides.html)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "ofn-guillotine-layer.html"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-guillotine-layer.html)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "ofn-export-layers.html"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-export-layers.html)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "Menu.png"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\Menu.png)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "LayersAndGroups.png"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\LayersAndGroups.png)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "HierarchicalExport.png"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\HierarchicalExport.png)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "FlatExport.png"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\FlatExport.png)
Uitvoeren van dochterproces is mislukt (Exec format error)
Translation:
"Kan opgegeven module niet vinden." = "Cannot find specified module."
"Uitvoeren van dochterproces is mislukt" = "Execution of daughter process failed"
Posts: 6,349
Threads: 274
Joined: Oct 2016
Reputation:
565
Operating system(s):
Gimp version: 2.10
(02-29-2024, 06:33 PM)gimpygirl Wrote: (02-29-2024, 12:07 PM)Ofnuts Wrote: Yes, in the Gimp standard error stream. But on Windows it is typically hidden (but I think you can get at it if you start Gimp with gimp-console.exe).
Otherwise:
- You can catch the worst blunders (unbalanced parentheses, indentation...) by trying to run the code in a command prompt (it should fail, but not elicit syntax errors)
- You bracket the code in a try/except block, and display the Python error in a Gimp message.
See examples in most of my scripts....
How to run code in command prompt?
I found the gimp-console.exe but it doesn't show gimp, only a bunch of errors. Should it show GIMP and the console at the same time, right? Here is does not show gimp
What to do to remove the errors?
Code:
GEGL-Message: 19:30:45.047: Module 'F:\Programma\GIMP 2\lib\gegl-0.4\exr-save.dll' load error: 'F:\Programma\GIMP 2\lib\gegl-0.4\exr-save.dll': Kan opgegeven module niet vinden.
GEGL-Message: 19:30:45.047: Module 'F:\Programma\GIMP 2\lib\gegl-0.4\exr-load.dll' load error: 'F:\Programma\GIMP 2\lib\gegl-0.4\exr-load.dll': Kan opgegeven module niet vinden.
Skipping duplicate plug-in: 'F:\Programma\GIMP 2\lib\gimp\2.0\plug-ins\ofn-export-layers\ofn-export-layers.html'
Skipping duplicate plug-in: 'F:\Programma\GIMP 2\lib\gimp\2.0\plug-ins\ofn-guillotine-layer\ofn-guillotine-layer.html'
GIMP-Fout: Unable to run plug-in "ofn-tiles.html"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-tiles.html)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "ofn-preset-guides.log"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-preset-guides.log)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "ofn-preset-guides.ini"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-preset-guides.ini)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "ofn-preset-guides.html"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-preset-guides.html)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "ofn-guillotine-layer.html"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-guillotine-layer.html)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "ofn-export-layers.html"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-export-layers.html)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "Menu.png"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\Menu.png)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "LayersAndGroups.png"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\LayersAndGroups.png)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "HierarchicalExport.png"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\HierarchicalExport.png)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "FlatExport.png"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\FlatExport.png)
Uitvoeren van dochterproces is mislukt (Exec format error)
Translation:
"Kan opgegeven module niet vinden." = "Cannot find specified module."
"Uitvoeren van dochterproces is mislukt" = "Execution of daughter process failed"
- Gimp is trying to run the HTML/PNG files that were in the ZIP. Just erase them or move them elsewhere
- You have plug-ins copied to both the Gimp installation (F:\Programma\GIMP 2\lib\gimp\2.0\plug-ins\) and your profile (C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\)
- No fatal error I can see, if this is the whole console Gimp should normally appear in another window
Posts: 74
Threads: 20
Joined: Feb 2024
Reputation:
0
Operating system(s):
- Windows Vista or 7, 8, 10 (64-bit)
Gimp version: 2.10
03-01-2024, 12:28 AM
(This post was last modified: 03-01-2024, 12:28 AM by gimpygirl.)
(02-29-2024, 11:34 PM)Ofnuts Wrote: (02-29-2024, 06:33 PM)gimpygirl Wrote: (02-29-2024, 12:07 PM)Ofnuts Wrote: Yes, in the Gimp standard error stream. But on Windows it is typically hidden (but I think you can get at it if you start Gimp with gimp-console.exe).
Otherwise:
- You can catch the worst blunders (unbalanced parentheses, indentation...) by trying to run the code in a command prompt (it should fail, but not elicit syntax errors)
- You bracket the code in a try/except block, and display the Python error in a Gimp message.
See examples in most of my scripts....
How to run code in command prompt?
I found the gimp-console.exe but it doesn't show gimp, only a bunch of errors. Should it show GIMP and the console at the same time, right? Here is does not show gimp
What to do to remove the errors?
Code:
GEGL-Message: 19:30:45.047: Module 'F:\Programma\GIMP 2\lib\gegl-0.4\exr-save.dll' load error: 'F:\Programma\GIMP 2\lib\gegl-0.4\exr-save.dll': Kan opgegeven module niet vinden.
GEGL-Message: 19:30:45.047: Module 'F:\Programma\GIMP 2\lib\gegl-0.4\exr-load.dll' load error: 'F:\Programma\GIMP 2\lib\gegl-0.4\exr-load.dll': Kan opgegeven module niet vinden.
Skipping duplicate plug-in: 'F:\Programma\GIMP 2\lib\gimp\2.0\plug-ins\ofn-export-layers\ofn-export-layers.html'
Skipping duplicate plug-in: 'F:\Programma\GIMP 2\lib\gimp\2.0\plug-ins\ofn-guillotine-layer\ofn-guillotine-layer.html'
GIMP-Fout: Unable to run plug-in "ofn-tiles.html"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-tiles.html)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "ofn-preset-guides.log"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-preset-guides.log)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "ofn-preset-guides.ini"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-preset-guides.ini)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "ofn-preset-guides.html"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-preset-guides.html)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "ofn-guillotine-layer.html"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-guillotine-layer.html)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "ofn-export-layers.html"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-export-layers.html)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "Menu.png"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\Menu.png)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "LayersAndGroups.png"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\LayersAndGroups.png)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "HierarchicalExport.png"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\HierarchicalExport.png)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "FlatExport.png"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\FlatExport.png)
Uitvoeren van dochterproces is mislukt (Exec format error)
Translation:
"Kan opgegeven module niet vinden." = "Cannot find specified module."
"Uitvoeren van dochterproces is mislukt" = "Execution of daughter process failed"
- Gimp is trying to run the HTML/PNG files that were in the ZIP. Just erase them or move them elsewhere
- You have plug-ins copied to both the Gimp installation (F:\Programma\GIMP 2\lib\gimp\2.0\plug-ins\) and your profile (C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\)
- No fatal error I can see, if this is the whole console Gimp should normally appear in another window
- check!
- check!
- unfortunately GIMP does not run, no matter how long I wait A bug?
Posts: 6,349
Threads: 274
Joined: Oct 2016
Reputation:
565
Operating system(s):
Gimp version: 2.10
(03-01-2024, 12:28 AM)gimpygirl Wrote: (02-29-2024, 11:34 PM)Ofnuts Wrote: (02-29-2024, 06:33 PM)gimpygirl Wrote: How to run code in command prompt?
I found the gimp-console.exe but it doesn't show gimp, only a bunch of errors. Should it show GIMP and the console at the same time, right? Here is does not show gimp
What to do to remove the errors?
Code:
GEGL-Message: 19:30:45.047: Module 'F:\Programma\GIMP 2\lib\gegl-0.4\exr-save.dll' load error: 'F:\Programma\GIMP 2\lib\gegl-0.4\exr-save.dll': Kan opgegeven module niet vinden.
GEGL-Message: 19:30:45.047: Module 'F:\Programma\GIMP 2\lib\gegl-0.4\exr-load.dll' load error: 'F:\Programma\GIMP 2\lib\gegl-0.4\exr-load.dll': Kan opgegeven module niet vinden.
Skipping duplicate plug-in: 'F:\Programma\GIMP 2\lib\gimp\2.0\plug-ins\ofn-export-layers\ofn-export-layers.html'
Skipping duplicate plug-in: 'F:\Programma\GIMP 2\lib\gimp\2.0\plug-ins\ofn-guillotine-layer\ofn-guillotine-layer.html'
GIMP-Fout: Unable to run plug-in "ofn-tiles.html"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-tiles.html)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "ofn-preset-guides.log"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-preset-guides.log)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "ofn-preset-guides.ini"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-preset-guides.ini)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "ofn-preset-guides.html"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-preset-guides.html)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "ofn-guillotine-layer.html"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-guillotine-layer.html)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "ofn-export-layers.html"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\ofn-export-layers.html)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "Menu.png"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\Menu.png)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "LayersAndGroups.png"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\LayersAndGroups.png)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "HierarchicalExport.png"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\HierarchicalExport.png)
Uitvoeren van dochterproces is mislukt (Exec format error)
GIMP-Fout: Unable to run plug-in "FlatExport.png"
(C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\FlatExport.png)
Uitvoeren van dochterproces is mislukt (Exec format error)
Translation:
"Kan opgegeven module niet vinden." = "Cannot find specified module."
"Uitvoeren van dochterproces is mislukt" = "Execution of daughter process failed"
- Gimp is trying to run the HTML/PNG files that were in the ZIP. Just erase them or move them elsewhere
- You have plug-ins copied to both the Gimp installation (F:\Programma\GIMP 2\lib\gimp\2.0\plug-ins\) and your profile (C:\Users\gebruiker\AppData\Roaming\GIMP\2.10\plug-ins\)
- No fatal error I can see, if this is the whole console Gimp should normally appear in another window
- check!
- check!
- unfortunately GIMP does not run, no matter how long I wait A bug?
Is there a Gimp instance running already? Do you see something in the process manager?
|