Why is it so hard to create a plugin. I am trying to write a simple plugin to export the current image to a PNG file and then close the view. I am stuck at the save the image. Plugin attached.
Thanks6 for the upload- it should have had the extension. Yes it is ai generated - Google does well most of the time when writing python script but has fallen completely flat on gimp plugins(He likes to think gimp2 is still a thing). Documentation seem very sparse for this. Yes the paths are hardcoded - easier than figure out what gimp can or can't do when it took hours for me to figure out how to get it to even show up. I'm trying to fixup a lot of images and the export process is so long - complicated by something has taken hold of the keyboard shortcut for export. I finally changed it. Then it comes up with a name dialog where I sometimes have to change from jpg to PNG then another dialog comes up with no buttons (weird) and I have to move this dialog slightly and the final parameter dialog comes up. Tedious.
def run(self, procedure, run_mode, image, n_drawables, drawables, args):
"""
Commented-out but save for future use.
I find this easier to use than the console.
if image is None:
Gimp.message('This plug-in requires an opened image.')
return failed(procedure)
# Get the original image filename
image_file = image.get_file()
if image_file:
original_file_path = image_file.get_path()
else:
# Handle images that haven't been saved yet.
Gimp.message(
"Image has no filename.\n"
"Please save the original file first."
)
return failed(procedure)
# Use pathlib to easily handle path components.
original_path, file_name = os.path.split(original_file_path)
new_file_name = os.path.splitext(file_name)[0] + '.png'
Thanks - I will try it out. Close while helpful isn't too bad as you can close all images and tell it not to save any. Still would be nice. Ok tried it out - export takes some time so if you don't wait you might get an incomplete image. Image close would help here a lot, surprised there is no option for this (I found some documentation but I can't find that feature either. Thanks - It has speed-ed up my work considerably.