Re: [Gimp-user] How to get the positions(x, y) (width, depth) of selected rectangle or selected ellipse
- From: Ofnuts <ofnuts gmx com>
- To: gimp-user-list gnome org
- Subject: Re: [Gimp-user] How to get the positions(x, y) (width, depth) of selected rectangle or selected ellipse
- Date: Mon, 17 Feb 2020 14:11:46 +0100
If you register your script properly, the Image will be in the function
arguments when the script is called from the menu,
no need to read it out from the title bar.
Also, you can avoid a lot of back-slashing by either:
- Using "raw" notation for string literals:
file_name = r'c:\Users\YourName\Documents\Temp\SampleXcfCsv.txt'
- Using triple quoting:
file_name='''c:\Users\YourName\Documents\Temp\SampleXcfCsv.txt'''
- Using forward slashes, that work just as well (the Windows API
understands both types, it's just the command-prompt parser
that insists on backslashes):
file_name="c:/Users/YourName/Documents/Temp/SampleXcfCsv.txt"
On 2/17/20 2:31 AM, ShiroYuki Mot via gimp-user-list wrote:
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])
- References:
- [Gimp-user] How to get the positions(x, y) (width, depth) of selected rectangle or selected ellipse
- Re: [Gimp-user] How to get the positions(x, y) (width, depth) of selected rectangle or selected ellipse
- Re: [Gimp-user] How to get the positions(x, y) (width, depth) of selected rectangle or selected ellipse
- Re: [Gimp-user] How to get the positions(x, y) (width, depth) of selected rectangle or selected ellipse
- [Gimp-user] How to get the positions(x, y) (width, depth) of selected rectangle or selected ellipse
- Re: [Gimp-user] How to get the positions(x, y) (width, depth) of selected rectangle or selected ellipse
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]