Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Does Script-Fu support input/output of the files?
#1
Photo 
Hi guys, I'm using Gimp 2.10.36 and need to find the coordinates of selected bounding box using this python code:

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)
Reply


Messages In This Thread
Does Script-Fu support input/output of the files? - by esm - 05-15-2024, 09:38 PM

Forum Jump: