by vndep » 24 Jun 2019, 16:29
Any thoughts on an efficient way to center a textbox in a python script?
For background, the script starts with an image and adds a layer of text. I want to make sure that the center of the textbox aligns with a specific X,Y coordinate in the image. To clarify, I am not thinking about left/center/right justification within the textbox.
I do not know in advance what text will be in the textbox. It could be of any length and include narrow characters (such as "i") or wide characters (such as "W")
My original thought was to somehow grab the X,Y coordinates of the four corners of the textbox (or maybe height and length) and then do some algebra to figure out to where I should move the textbox.
The only function that seems relevant is pdb.gimp_selection_bounds; however the parameter for that function is an image rather than a layer.
Anticipating a follow up question, I am not having any luck finding the python function that would allow me to move the textbox, either.
Thanks in advance!
Any thoughts on an efficient way to center a textbox in a python script?
For background, the script starts with an image and adds a layer of text. I want to make sure that the center of the textbox aligns with a specific X,Y coordinate in the image. To clarify, I am not thinking about left/center/right justification within the textbox.
I do not know in advance what text will be in the textbox. It could be of any length and include narrow characters (such as "i") or wide characters (such as "W")
My original thought was to somehow grab the X,Y coordinates of the four corners of the textbox (or maybe height and length) and then do some algebra to figure out to where I should move the textbox.
The only function that seems relevant is pdb.gimp_selection_bounds; however the parameter for that function is an image rather than a layer.
Anticipating a follow up question, I am not having any luck finding the python function that would allow me to move the textbox, either.
Thanks in advance!