GIMP Chat
http://gimpchat.com/

Extract Object plugin question
http://gimpchat.com/viewtopic.php?f=9&t=20111
Page 1 of 1

Author:  Pocholo [ Sun Sep 11, 2022 8:25 pm ]
Post subject:  Extract Object plugin question

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. :)

Author:  mahvin [ Mon Sep 12, 2022 1:56 am ]
Post subject:  Re: Extract Object plugin question

Provide him the xcf and he'll be able to check it.

Author:  ofnuts [ Mon Sep 12, 2022 5:47 am ]
Post subject:  Re: Extract Object plugin question

#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 491 times ]

Author:  Pocholo [ Mon Sep 12, 2022 10:39 am ]
Post subject:  Re: Extract Object plugin question

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

Author:  teapot [ Mon Sep 12, 2022 10:42 am ]
Post subject:  Re: Extract Object plugin question

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?

Author:  ofnuts [ Mon Sep 12, 2022 12:21 pm ]
Post subject:  Re: Extract Object plugin question

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 :)

Author:  Pocholo [ Mon Sep 12, 2022 12:49 pm ]
Post subject:  Re: Extract Object plugin question

@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

Author:  ofnuts [ Mon Sep 12, 2022 2:51 pm ]
Post subject:  Re: Extract Object plugin question

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))

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/