05-15-2024, 09:38 PM
Hi guys, I'm using Gimp 2.10.36 and need to find the coordinates of selected bounding box using this python code:
I'm wondering if there is a way to write the contents of a gimp.message(the coordinates) directly to a txt file? Can you please provide some examples?
This is the output I want to get - a created txt file with the same name as the image and 4 coordinates inside:
This is the code I found but it's written in Scheme (Lisp dialect) and I don't understand how to rewrite it in python.
Code:
from gimpfu import *
import os
def foo():
selection, x1, y1, x2, y2 = pdb.gimp_selection_bounds(gimp.image_list()[0])
if not selection:
pdb.gimp_message("No selection")
else:
gimp.message('%d, %d, %d, %d' % (y1, x1, y2, x2))
register(...)
main()
I'm wondering if there is a way to write the contents of a gimp.message(the coordinates) directly to a txt file? Can you please provide some examples?
This is the output I want to get - a created txt file with the same name as the image and 4 coordinates inside:
This is the code I found but it's written in Scheme (Lisp dialect) and I don't understand how to rewrite it in python.
Code:
(define outport (open-output-file "samplefile.txt")) (display "Hello" outport)
(newline outport)
(display "World" outport)
(close-output-port outport)