Gimp-Forum.net
Creating a path from the center points of a selection? - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: General questions (https://www.gimp-forum.net/Forum-General-questions)
+--- Thread: Creating a path from the center points of a selection? (/Thread-Creating-a-path-from-the-center-points-of-a-selection)

Pages: 1 2


Creating a path from the center points of a selection? - eepjr24 - 11-13-2020

If I have a selection, for simplicity sake we'll start with a 50 pixel wide line at a 45 degree angle from top left to bottom right. How do I create a path that traverses the approximate center of the selection and is one pixel wide?

I know how to create a selection, shrink a selection, create a path from a selection. But simply shrinking will either end you up with gaps in the path or with areas that are wider than a pixel in the path if there is any deviation in the width. I am fine if this is something I need to do programatically (learning Python, know multiple other languages) if someone can point me in the right direction or the terminology to look for to execute this type of operation. I am no great mathematician, but I can muddle through most geometry and basic trig. And I am fine with putting in time to experiment as necessary.

Edit: Using GIMP 2.10.22 but can upgrade if needed, Win 10 64 bit.

- Ernie


RE: Creating a path from the center points of a selection? - denzjos - 11-14-2020

I tried this: 
- select the black line with the Fuzzy Selection Tool
gimp menu :
- Select / To Path
- Select / None
- on path, right click : 
  - Tools / Cropping and Slicing / Crop path by rectangle
  - Edit / Break path apart
  - Tools / Generate intermediate paths  (3)
done (maybe ofnuts can suggest a shorter way to do this)
[attachment=5192]


RE: Creating a path from the center points of a selection? - rich2005 - 11-14-2020

For a single pixel, it is going to be either, paint in by hand with the pencil tool, or stroke a path again with the pencil tool. 

No way that I can see for exact end-to-end other than manual editing.

Assuming the line is going to be something more that a single diagonal line, there is a plugin that uses an external program 'autotrace' see: http://gimpchat.com/viewtopic.php?f=9&t=17485

Might look like this:

[attachment=5193]

An alternative is the Inkscape application (use last 0.92 series) which does the same and has autotrace built in.


RE: Creating a path from the center points of a selection? - mholder - 11-14-2020

- on path, right click : 
  - Tools / Cropping and Slicing / Crop path by rectangle
  - Edit / Break path apart
  - Tools / Generate intermediate paths  (3)



Where do I find these options?


RE: Creating a path from the center points of a selection? - denzjos - 11-14-2020

Cropping : https://www.gimp-forum.net/Thread-Cropping-and-slicing-a-path
the rest can you find in the Ofnuts download table : https://sourceforge.net/p/gimp-path-tools/activity/?page=0&limit=100#5e00bcaaee24ca3708eac697

@Rich, after stroke the line it is not possible to get a 1 pixel line, the outlines are 1 pixel.  
[attachment=5194]


RE: Creating a path from the center points of a selection? - rich2005 - 11-14-2020

(11-14-2020, 11:52 AM)denzjos Wrote: @Rich, after stroke the line it is not possible to get a 1 pixel line, the outlines are 1 pixel.  

Sorry, I do not really understand the question, however there is a difference between stroking a path with a 1 pix. anti-aliasing off, line and stroking with a 1 pix pencil tool.

[attachment=5195]


RE: Creating a path from the center points of a selection? - mholder - 11-14-2020

" - Edit / Break path apart"

Ok which script does this?

@Ofnuts: Is there a single zip file with all your scripts?


RE: Creating a path from the center points of a selection? - Krikor - 11-14-2020

(11-14-2020, 01:42 PM)mholder Wrote: " - Edit / Break path apart"

Ok which script does this?

@Ofnuts: Is there a single zip file with all your scripts?

ofn-path-edits.py


RE: Creating a path from the center points of a selection? - mholder - 11-14-2020

Ok got it thanks!

I tried this: 
- select the black line with the Fuzzy Selection Tool     (ok)
gimp menu :
- Select / To Path  (ok)
- Select / None     (ok)
- on path, right click : 
  - Tools / Cropping and Slicing / Crop path by rectangle  (error, then I use canvas option)
  - Edit / Break path apart   (ok)
  - Tools / Generate intermediate paths  (3)    (does nothing)

So what am I doing wrong here?  I can already think of many uses for this if I can get it to work.


RE: Creating a path from the center points of a selection? - Ottia Tuota - 11-14-2020

(11-14-2020, 02:11 PM)mholder Wrote: I tried this: 
...
  - Tools / Cropping and Slicing / Crop path by rectangle  (error, then I use canvas option)
...

Could you please tell: What error? What kind of a path? What rectangle option you tried - rectangular selection, guides, or active layer? A picture would tell much. Errors may mean bugs in the code, so I am interested.

If you use the canvas option, it may well be that cropping does nothing, depending on the situation.