Re: [Gimp-user] How to get the positions(x, y) (width, depth) of selected rectangle or selected ellipse



Please learn the basic scripting of GIMP Python.
See as follows.
https://www.gimp.org/docs/python/index.html

If opened image by GIMP is one only at first and it has one layer and a
selection is existing.
Example on Windows OS - Python Console.

image = gimp._id2image(1)
# 1 is shown at GIMP Title-Bar as '[Name] (Status)- 1.0 (RGB ...'
image
import csv
file_name = "c:\\Users\\YourName\\Documents\\Temp\\SampleXcfCsv.txt"
file_name
non_empty, x1, y1, x2, y2 = pdb.gimp_selection_bounds(image)
x1
y1
x2
y2
with open(file_name, 'w') as f:
  writer = csv.writer(f)
  writer.writerow([x1, y1, x2, y2])

2020年2月17日(月) 9:52 tamasakai <forums gimpusers com>:

Dear Ofnuts. Thanks!  ;) There was a good way!

Is it OK?
2020年2月14日(金) 16:34 Ofnuts <ofnuts gmx com>:

Thank you for all members replied to my questions.
I am jast a biginner of GIMP.
So please tell me step by step with patience.

Then, I wrote a script, made a image named "sample.xcf" and made a
rectangle
selection on it.
The script on Python Consol made errors.
What should I do next?
--------------------------------
# How to get the positions(x, y) (width, depth) of selected rectangle or
selected ellipse
 (non_empty,x1,y1,x2,y2) = selection_bounds (sample.xcf)
with open(file_name, 'w') as f:
 writer = csv.writer(f)
 writer.writerow([x1, y1, x2, y2])
 main()
------------------------------


--
tamasakai (via www.gimpusers.com/forums)
_______________________________________________
gimp-user-list mailing list
List address:    gimp-user-list gnome org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list
List archives:   https://mail.gnome.org/archives/gimp-user-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]