Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Divide straight line with "notches" (e.g. graph scale)
#1
Hi all, I'm looking to put a "scale" on an image. It's actually a map that I'm cropping a region from. So, I need to be able to draw a straight line on the full size original, between two known points, and divide that into a specific number of subdivisions (e.g. miles, but more likely minutes of lat/long in my situation).

Ideally, the result would put "tick marks", or "notches" along the line, in the manner of a graph scale, but as long as the points are identifiable I could do that by hand. 

After all that, I would then crop the image, leaving some part of the line in the crop to act as the new scale.

I found this thread:
https://www.gimp-forum.net/Thread-ofn-br...es-on-path

which I think I could make work, but I suspect it's unnecessarily complex, since the target of "equal division" is an arbitrary path. I'm hoping there's a better/simpler/faster approach for the straight line situation?

Any pointers?

TIA,
Toby
Reply
#2
A straight line (path) can be divided with a plugin from Ottia Tuota : 
http://kmarkku.arkku.net/

Use the plugin 'Chop a path by lenghts'
Example :
   
Reply
#3
As a possible alternative, how about a checker pattern, often seen on maps.

   

New Layer
Make a selection between grid lines
Apply  Filters-> Render -> Pattern -> Checkerboard to the selection and adjust 
Kill selection.
Layer -> Crop to content

50 second animation of that: https://i.imgur.com/rDE8XUR.mp4  Of course Gimp is a bitmap editor, images are pixel sizes and always a chance of being a pixel or two out.
Reply
#4
With my ofn-path-inbetweener script:

* Create a path for the left notch
* Create a path for the right notch
* Call the script to generate the intermediate strokes for a total of N strokes, including copies of left and right:


   
   
   
Reply
#5
(07-13-2023, 06:49 PM)rich2005 Wrote: As a possible alternative, how about a checker pattern [...].
Hmm, that looks promising.

But as far as I can tell, I choose the pixel height of the checkers, rather than the number of them, is that correct?

I think that might give me a bit more rounding error than is desirable.

I have 6828 pixels spanning 7.5 minutes of latitude, I planned to divided into 45 blocks of ten-seconds of latitude each. That ends up as 151.7333 pixels per block, so if I round up, I'll be, er... 10 pixels off by the end.

Well, I'll give it a try, it might not matter. Thanks for the idea!

(07-13-2023, 06:15 PM)denzjos Wrote: A straight line (path) can be divided with a plugin from Ottia Tuota : 
http://kmarkku.arkku.net/

Use the plugin 'Chop a path by lenghts'
Example :

This looks like it could work...
Currently struggling to get my installation to notice plugins (I've never used one before  Sad )

(07-13-2023, 07:36 PM)Ofnuts Wrote: With my ofn-path-inbetweener script:
This looks practically perfect. Now, if I can just get my system to recognize plugins, I should have a pretty decent chance.
Thanks, I'll be working to try to get this running.

(07-13-2023, 07:36 PM)Ofnuts Wrote: With my ofn-path-inbetweener script:
I wonder if you'd be willing to help me get this installed?

I've added the .py file to both my scripts directory and my plugins directory (I wasn't sure which it might by, so went with both). I've restarted GIMP, and I've run "refresh scripts", but I don't see anything promising in a menu (but since I don't know where to look, I guess I could easily have missed it) neither do i see anything if I use the "help->search and run a command" thing, but I'm not sure what the name would be (I looked for "between" and got nothing).
Any pointers?
TIA
Reply
#6
(07-13-2023, 07:36 PM)Ofnuts Wrote: With my ofn-path-inbetweener script:

* Create a path for the left notch
* Create a path for the right notch
* Call the script to generate the intermediate strokes for a total of N strokes, including copies of left and right:

I had completely forgotten about that option! But maybe it's the one I would use in this situation.

Other options I can think of would be:
1- The ofn-path-rungs.py plugin (used in the top map of the image below);

2- The Brush strokes on path plugin (used on the bottom map)
   

I think that with ofn-path-to-shape.py it would also be possible to create spaced markers like those of a ruler, but I couldn't remember how it would be.

If necessary, I could explain better how to use the 2 plugins mentioned at the beginning, but I think using ofn-path-inbetweener (hey, difficult name to write!) would be enough.
                               .....
Samj PortableGimp 2.10.28 - Win-10 /64.
Reply
#7
I think that the solution has been presented (even a couple of options!) However, I'm utterly failing to install/find the utility. I should note that I've never used a plugin or script before in GIMP. Any chance anyone can help me debug this? (Perhaps relevant, I'm using GIMP 2.10.30)

I've tried to follow the user guide notes that I found, but could easily have missed something. Here are the steps I followed:

1) download the zip. I got a file: ofn-path-inbetweener.zip
2) extract the contents and copy it into my scripts directory (I also copied it to the Plugins directory first because I thought it was a plug in) Below, I hope, describes the result most effectively:
   
and:
$ ls -l /home/simon/snap/gimp/393/.config/GIMP/2.10/scripts
total 12
-rwxr-xr-x 1 simon simon 10499 Jul 13 14:03 ofn-path-inbetweener.py


But I can't find how to start the tool. The help info suggests it might show up under a menu, but there are lots and I've failed to find it there. Help also suggests using a "search actions" feature, but if I try "between" in that, I get nothing:

   

I'm guessing I'm missing something very basic, but I've not found any advice on this in help (it's hard to look for "nothing happens"  Big Grin )

Can anyone guide me?
Reply
#8
(07-14-2023, 03:28 PM)TobyEggitt Wrote: 2) extract the contents and copy it into my scripts directory (I also copied it to the Plugins directory first because I thought it was a plug in) Below, I hope, describes the result most effectively:
Can anyone guide me?

I was a bit suspicious when your profile said Gimp 2.8 Wink

Well, you were correct first time, because it is a plugin, but it is a python plugin and since you have a Gimp 2.10.30 you will not have a gimp-python package.

Look in Filters and if there is no Python-Fu entry then no working python plugins.

   

What linux distro do you use ? If ubuntu or a spin-off then it might be possible to add python support.
or
Install a flatpak Gimp, that comes with python support built in (and some snags as well)

Give a few more details
Reply
#9
(07-14-2023, 04:49 PM)rich2005 Wrote: Look in Filters and if there is no Python-Fu entry then no working python plugins.

Aha! You're dead on that there's no "Python-fu" entry in the menus.I'm using Ubuntu 20.04. I have Python 3.10.1 and 2.7.18 installed, though I guess it's the GIMP end of things that's not playing ball?

Ubuntu doesn't seem to like flatpak very much, at least I've never gotten it to work yet. I'd prefer to try other approaches, perhaps simply build from source, initially rather than mess with that.

What version do I need to make this possible? And if I find / build it, is there configuration, or if a python interpreter is on my $PATH, will it "just work"?

I found this: https://www.gimp.org/docs/python/index.html ... can I perhaps simply build / install the "gimpmodule" as they describe in section 1.2? If so, I guess the next question is where do I find the source?

Thanks for the guidance!
Reply
#10
Still on 20.04? IIRC it's out of service since April.

As far as I remember flatpak works.

Installing the gimp-python .deb from an earlier Ubuntu release (19.10 likely the latest) may be the easiest way, see here.

Building from source is doable (this is what I do, for this and other reasons) but if you are on 20.04 and want a recent Gimp you will have to build many other dependencies from source, so I would advise to move to 22.04 first.
Reply


Forum Jump: