It is currently Wed Jun 26, 2024 1:43 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Extract Object plugin question
PostPosted: Sun Sep 11, 2022 8:25 pm  (#1) 
Offline
GimpChat Member

Joined: Jul 28, 2018
Posts: 1196
Hi! This question is particularly for ofnuts, who wrote the plugin, but if other coder know the answer, go head and answer.

I tried the plugin and I love it, but when I run it on a Text it will not create the layers in order. Why does it jump the order?
For example, the letter "O" is on the position 1 in the layer's stack. It should run S, H, A, D, O, W, like I stated before, in order from top to bottom/left to right. Thank you in advanced. :)

_________________
https://www.deviantart.com/pocholo17
Image


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Extract Object plugin question
PostPosted: Mon Sep 12, 2022 1:56 am  (#2) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4050
Provide him the xcf and he'll be able to check it.

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: Extract Object plugin question
PostPosted: Mon Sep 12, 2022 5:47 am  (#3) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4750
#1: The script doesn't know that you start with text. For other types of layers, the order is pretty much arbitrary.

#2: The script makes a selection, and then obtains a path from it, and then works on the path strokes. So the output is the order in which the path2sel plugin creates strokes. Thinking about it, paths2sel probably scans lines from top, so the first stroke is the item with the "highest" pixel. And the O being a round character, is possibly a tad higher that the others to make it visually just as tall (you can also check that is extends slightly below the baseline for the same reason).

It wouldn't be hard to write a script to reorder layers by their offset.

Also, if you are working with text layers, my "ofn-path-edits" plugin has a "Break text path apart" function that works on the text path (and IIRC should preserve the character order, at least in LTR languages):

Attachment:
ksnip_20220912-124530.png
ksnip_20220912-124530.png [ 38.75 KiB | Viewed 489 times ]

_________________
Image


Top
 Post subject: Re: Extract Object plugin question
PostPosted: Mon Sep 12, 2022 10:39 am  (#4) 
Offline
GimpChat Member

Joined: Jul 28, 2018
Posts: 1196
Thank you mahvin for the input and yes, I should it provided a sample image.

onuts, I appreciate you reaching out and for the explanation and answer. I want insert part of your script into a new text effect plugin I'm try to write. I will give you credit for that part of the plugin. I will try "ofn-path-edits". :tyspin

_________________
https://www.deviantart.com/pocholo17
Image


Top
 Post subject: Re: Extract Object plugin question
PostPosted: Mon Sep 12, 2022 10:42 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: Dec 09, 2018
Posts: 656
ofnuts wrote:
So the output is the order in which the path2sel plugin creates strokes. Thinking about it, paths2sel probably scans lines from top, so the first stroke is the item with the "highest" pixel.

Did you mean sel2path?


Top
 Post subject: Re: Extract Object plugin question
PostPosted: Mon Sep 12, 2022 12:21 pm  (#6) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4750
teapot wrote:
ofnuts wrote:
So the output is the order in which the path2sel plugin creates strokes. Thinking about it, paths2sel probably scans lines from top, so the first stroke is the item with the "highest" pixel.

Did you mean sel2path?


Quite possibly :)

_________________
Image


Top
 Post subject: Re: Extract Object plugin question
PostPosted: Mon Sep 12, 2022 12:49 pm  (#7) 
Offline
GimpChat Member

Joined: Jul 28, 2018
Posts: 1196
@ofnuts - I use the font "Arial Heavy" and you're right. The size of the letter "O" is higher than the rest of the letters. I guess have to pick a font that each characters are the same size in order for the plugins to work. Thank you for your work creating all those wonderful plugins! :jumpclap :clap

_________________
https://www.deviantart.com/pocholo17
Image


Top
 Post subject: Re: Extract Object plugin question
PostPosted: Mon Sep 12, 2022 2:51 pm  (#8) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4750
Pocholo wrote:
I guess have to pick a font that each characters are the same size in order for the plugins to work.


No, instead of having unnatural restrictions (because most fonts have characters of different height) you have to sort your layers by the X coordinates of their offset. Basic stuff:

* Copy affected layers to array/list (comprehension)
* Sort array/list (providing a "key" function that extracts the X offset) (possibly have to specify a reverse order)
* Iterate array and move each layer in turn to position 0 (pdb.gimp_image_reorder_item(image, item, parent, position))

_________________
Image


Top
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Scan in and extract URLs using GIMP

8

No new posts GEGL filter to Extract, Recolor and Blur a Brightness Channel

1

No new posts Attachment(s) GEGL Edge Extract - Edge Neon's algorithm in transparent background

9

No new posts Map to Object

3

No new posts Attachment(s) Quick and Dirty Lightning Object

2



* Login  



Powered by phpBB3 © phpBB Group