Hi goran,
Thank you for sharing your first script. I appreciate getting into new things isn't easy so will just mention one thing.
In gimp if you do the menu item:
Filters -> Python-Fu -> Console
Then hit the Browse button
You can search for the function you want to call, so in your case gimp_selection_bounds.
When that comes up hit the apply button. Then look in the console window, and copy and paste the result into your code:
non_empty, x1, y1, x2, y2 = pdb.gimp_selection_bounds(image)
You can use the above one line to replace the following lines you currently have (changing non_empty and image to your preferred variable names) as there is no need for the multiple calls:
pdb.gimp_selection_bounds(img)
selection_exists = pdb.gimp_selection_bounds(img)[0]
x1=pdb.gimp_selection_bounds(img)[1]
y1=pdb.gimp_selection_bounds(img)[2]
x2=pdb.gimp_selection_bounds(img)[3]
y2=pdb.gimp_selection_bounds(img)[4]
Thank you for sharing your first script. I appreciate getting into new things isn't easy so will just mention one thing.
In gimp if you do the menu item:
Filters -> Python-Fu -> Console
Then hit the Browse button
You can search for the function you want to call, so in your case gimp_selection_bounds.
When that comes up hit the apply button. Then look in the console window, and copy and paste the result into your code:
non_empty, x1, y1, x2, y2 = pdb.gimp_selection_bounds(image)
You can use the above one line to replace the following lines you currently have (changing non_empty and image to your preferred variable names) as there is no need for the multiple calls:
pdb.gimp_selection_bounds(img)
selection_exists = pdb.gimp_selection_bounds(img)[0]
x1=pdb.gimp_selection_bounds(img)[1]
y1=pdb.gimp_selection_bounds(img)[2]
x2=pdb.gimp_selection_bounds(img)[3]
y2=pdb.gimp_selection_bounds(img)[4]