It is currently Sat Jun 20, 2026 4:44 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Crosshair guides for the v3 dialect of ScriptFu.
PostPosted: Wed Mar 12, 2025 1:03 pm  (#1) 
Offline
GimpChat Member
User avatar

Joined: Dec 09, 2018
Posts: 734
Here's a plugin-in for the version 3 of Script-Fu. It puts guides on all selected drawables as a crosshair (one in the middle horizontally and one vertically). It's only short but I wanted to have a play with gimp 3, see how the selection of one or more drawables works. Menu is Image -> Guides -> Crosshair Guides v3.

#!/usr/bin/env gimp-script-fu-interpreter-3.0

(define (add-guides image drawable)

  (let* ((drawable-width (gimp-drawable-get-width drawable))
         (drawable-height (gimp-drawable-get-height drawable))
         (offsets (gimp-drawable-get-offsets drawable))
         (offset-x (car offsets))
         (offset-y (cadr offsets))
         (position-x (+ (/ drawable-width 2) offset-x))
         (position-y (+ (/ drawable-height 2) offset-y)))

        (gimp-image-add-vguide image position-x)
        (gimp-image-add-hguide image position-y)))

(define (script-fu-crosshair-guides-v3 image drawables)
    (script-fu-use-v3)

    (gimp-image-undo-group-start image)

    (do ((len (vector-length drawables))
         (i 0 (+ i 1)))
        ((= i len))
      ; (gimp-message (string-append "i: " (number->string i)))
        (add-guides image (vector-ref drawables i))
    )

    (gimp-image-undo-group-end image))

(script-fu-register-filter "script-fu-crosshair-guides-v3"
    "Crosshair Guides v3"
    "Place crosshair guides on all selected drawables."
    "teapot"
    "teapot"
    "2025"
    "*"
    SF-ONE-OR-MORE-DRAWABLE
)

(script-fu-menu-register "script-fu-crosshair-guides-v3" "<Image>/Image/Guides")


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: Crosshair guides for the v3 dialect of ScriptFu.
PostPosted: Thu Mar 13, 2025 3:23 am  (#2) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2603
Just to confirm that the script works nicely in a linux Gimp 3.0 RC3 appimage.
and a reminder that:

The script is a plugin and has to follow Gimp 3.0 requirements.

If you save the the script as crosshairs.scm then that goes in its own folder named crosshairs. That goes as a sub-folder in the Gimp User plug-ins folder.

Using linux ? Then crosshairs.scm is made executable.


Top
 Post subject: Re: Crosshair guides for the v3 dialect of ScriptFu.
PostPosted: Thu Mar 13, 2025 4:01 am  (#3) 
Offline
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 16037
Placed as an SCM in the scripts folder.
Works great in Windows x64 - Gimp-3.0-RC3 + GIT. Thanks teapot! :)

_________________
Image


Top
 Post subject: Re: Crosshair guides for the v3 dialect of ScriptFu.
PostPosted: Thu Mar 13, 2025 4:50 am  (#4) 
Offline
GimpChat Member
User avatar

Joined: Apr 15, 2017
Posts: 1837
rich2005 wrote:
Just to confirm that the script works nicely in a linux Gimp 3.0 RC3 appimage.
and a reminder that:

The script is a plugin and has to follow Gimp 3.0 requirements.

If you save the the script as crosshairs.scm then that goes in its own folder named crosshairs. That goes as a sub-folder in the Gimp User plug-ins folder.

Using linux ? Then crosshairs.scm is made executable.


I'm running Linux with Gimp 3.0 RC3 via PPA version. I just saved as scm and put it in the scripts folder, no sub-folder and it works fine here. I didn't make it executable either.

Are we supposed to put scripts in sub-folders too? I thought that was just for plugins.


Top
 Post subject: Re: Crosshair guides for the v3 dialect of ScriptFu.
PostPosted: Thu Mar 13, 2025 5:31 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: Dec 09, 2018
Posts: 734
Hi Rich, Rob And Racer-x Thanks for your comments.

Until now I had always installed it the new way as Rich described in post #2.

Just tried the old way as Rob described in post #3 and that looks to work too. However from a test of uncommenting the gimp message that was used just to see what's happening, the edit isn't automatically picked up.

Whereas using the new method the edit is automatically picked up:
Install as Rich described in post #2. (Note as he said the plug-ins directory not the scripts one).
Start gimp.
Run plug-in, it produces no gimp messages.
Edit plug-in to uncomment the gimp message.
Run plug-in again, a message for each selected layer appears that just contains a number e.g. i: 0, i: 1.
Edit again to comment out the message.

So I would stick to the new method as Rich described in post #2.

Note that this is a plug-in even though it's written in scheme.


Last edited by teapot on Thu Mar 13, 2025 6:04 pm, edited 1 time in total.

Top
 Post subject: Re: Crosshair guides for the v3 dialect of ScriptFu.
PostPosted: Thu Mar 13, 2025 8:31 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Dec 09, 2018
Posts: 734
More information on installation is here:
https://testing.developer.gimp.org/reso ... chitecture


Top
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group