You are here

Grid of guides

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Rate this item!
guides-grid.scm1.26 KB

Add a grid of guides from number of horizontal and vertical parts in GIMP.
Tested with GIMP 2.6

Code License: 
GIMP Version: 
Scripting Engine: 


I modified the script to work by specifying either the number of divisions (the current way) or by specifying the number of pixels for the guide spacing: ; Luigi Chiesa 2008. No copyright. Public Domain. ; Add a grid of guides (define (script-fu-grid-guides InImage InHGrid InVGrid InMode InBorder) (gimp-image-undo-group-start InImage) (let* ( (width (car (gimp-image-width InImage))) (height (car (gimp-image-height InImage))) (divH (if (= InMode 0) (/ width InHGrid) InHGrid)) (divV (if (= InMode 0) (/ height InVGrid) InVGrid)) (InHGrid (if (= InMode 0) InHGrid (/ width InHGrid))) (InVGrid (if (= InMode 0) InVGrid (/ height InVGrid))) (hcount 1) (vcount 1) ) (if (= InBorder TRUE) (begin (gimp-image-add-hguide InImage 0) (gimp-image-add-hguide InImage height) (gimp-image-add-vguide InImage 0) (gimp-image-add-vguide InImage width) ) ) (while (< hcount InVGrid) (gimp-image-add-hguide InImage (* divV hcount)) (set! hcount (+ hcount 1)) ) (while (< vcount InHGrid) (gimp-image-add-vguide InImage (* divH vcount)) (set! vcount (+ vcount 1)) ) (gimp-image-undo-group-end InImage) (gimp-displays-flush) ) ) (script-fu-register "script-fu-grid-guides" "/Image/Guides/Grid" "Add a grid of guides by specifying either the number of guides or the guide spacing" "Luigi Chiesa and Rob Antonishen" "Public Domain" "November 2009" "*" SF-IMAGE "Image" 0 SF-ADJUSTMENT "Horizontal" '(2 1 500 1 10 0 1) SF-ADJUSTMENT "Vertical" '(2 1 500 1 10 0 1) SF-OPTION "Mode" '("Number of Divisions" "Spacing of Guides (px)") SF-TOGGLE "Border guides?" FALSE )

RobA's modification wasn't recognized by the program. Could it be uncompatible with 2.6 somehow?

The original shows up in the guides selections as well as the script-fu scripts.

I use this script a lot and truly appreciate having it, however, I was just wondering if it were possible to create a centering set of guidelines (one click option) that is based on any drawing size? I have that same script in Paint Shop Pro written in Python.

I am not sure what you mean. Would that not be the same as a 2 by 2 division grid, without edge grids? -Rob A>

I have a script in Paint Shop Pro, that I created using Python, that places a vertical and horizontal guideline in the exact middle of any drawing I open, to help me find the center of that image, for using polar arrays, kaleidoscopes, or radial copy/duplications. It would need to be a guideline, not a grid, and I only have to click once to get both guidelines. With the current guide script that you modified (thank you, btw) I have to click twice to get vertical, then horizontal. I was just wondering if there was a way to make it do both at the same time.

I don't think so. The script creates a grid of guidelines, both horizontal and vertical. The modified script default gives what you are asking for: Horizontal = 2 Vertical = 2 Mode = Number of Divisions Border Guides unchecked. This creates a pair of guides centered on the image. -Rob A>

I took Chris Mohler's "Rules of Thirds" py script and removed the thirds and modified it to halves. I had to re-register and re-name the script so as to not confuse GIMP. This does what I want, but it still leaves me curious why the guides script can't have set guidelines hard coded into it instead of asking for user input. Or why not both, have it set the guidelines (like in my case) and have it asking for user input in other cases. Maybe it can, but I am just not asking in a way that makes sense. Like in Rules of Thirds, there is no user input, the script just calculates the guidelines into thirds, both vertically and horizontally, and when clicked, applies the guidelines automatically to the image. If anyone wants the modified "centered guidelines" python script, let me know, I'll post it.

If you are already using the ROT plug-in (it's installed), then you should rename the function as well - eg, replace both instances of "add_ROT_guides" with "add_center_guides" or similar. Doesn't really matter if you're not using ROT guides, but then again, that will look better in the Procedure Browser anyway... Chris

I thought of that, wanting to retain the ROT option, so now both show up in the menu. I can't thank you enough for this script. Anything to reduce mouse clicks is a plus, for me. :)

Script was useful, even more useful with RobA added option i like be able to set the spacing in pixels
Subscribe to Comments for "Grid of guides"