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



Dear Ofnuts. Thanks a lot!  :)

I wrote just the basic code, because he seems to be a beginner.
But your comments will surely help him.


2020-02-17 22:11 GMT+09:00, Ofnuts <ofnuts gmx com>:

Thank you all

I tried the script as follows.
I could get the selection's position and size!
Thanks again.
But the Python script only runs on GIMP 2.10.12 but GIMP.2.10.12
So I use it with downgraded GIMP because the script is very useful for me.

I will try it when new GIMP comes out
Thank you

---------------------------------
# coding:utf-8

import csv
import os.path
from gimpfu import *

outpath = "Z:\\outcsv\\data\\out.csv"

def plugin_main(image, layer):
    current_image = image #gimp.image_list()[0]
    filename = pdb.gimp_image_get_filename(current_image)
    non_empty, x1, y1, x2, y2 = pdb.gimp_selection_bounds(current_image)
    with open(outpath, 'a') as f:
        writer = csv.writer(f, lineterminator='\n')
        writer.writerow([x1,y1,x2-x1,y2-y1,filename])

register(
    "outcsv",#コマンドラインまたはスクリプトから呼び出す場合のコマンドの名前
    "output to csv",#プラグインの説明
    "out csv",#プラグインの詳細な説明
    "tamasakai",#プラグインの作成者
    "tamasakai(copyright)",#プラグインの著作権保有者 (通常は author と同じ)
    "2020/02/18",#著作権の日付
    "<Image>/Filters/Languages/Python-Fu/outcsv", #メニューの中でプラグインに使用されるラベル
    "RGB*, GRAY*", #プラグインで処理する対象となる画像のタイプex. RGB*, GRAY* など
    [],#引数(型, 名前(プロシージャブラウザに表示される),説明, 初期値)
    [], # 戻り値
    plugin_main) # メソッド名

main()
----------------------------------------------------------------




-- 
tamasakai (via www.gimpusers.com/forums)


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