Skip to Menu

GIMP Stuff

Code and experiments with the GNU Image Manipulation Program

Repeating Guidelines

The following Script-Fu creates multiple guides on the axis you define. Download guides-repeat.scm and save in your scripts folder (on Windows this would be C:\Program Files\GIMP-2.0\share\gimp\2.0\scripts (all users) or %USERPROFILE%\.gimp-2.6\scripts.

(define (script-fu-guide-repeat image
                             drawable
                             direction
                             separation)
  (let* (
        (width (car (gimp-image-width image)))
        (height (car (gimp-image-height image)))
  (position 0)
  )
 ; set maximum otherwise the guides will be added indefinitely
 (if (= direction 0)
   (set! max height)
   (set! max width)
 )
 ; while the position is less than the maximum
 (while (<= position max)

  (if (= direction 0)
   ;; check position is inside the image boundaries
   (if (<= position height) (gimp-image-add-hguide image position))
   (if (<= position width) (gimp-image-add-vguide image position))
  )
  
 ; increment position by defined separation 
 (set! position (+ position separation)))
 (gimp-displays-flush)
  )
)

(script-fu-register "script-fu-guide-repeat"
  _"R_epeating Guide"
  _"Add multiple guides separated by specified number of pixels"
  "Sam Collett"
  "Sam Collett"
  "2008-11-18"
  "*"
  SF-IMAGE      "Image"      0
  SF-DRAWABLE   "Drawable"   0
  SF-OPTION     _"Direction" '(_"Horizontal" _"Vertical")
  SF-ADJUSTMENT _"Separation"  (list 40 1 MAX-IMAGE-SIZE 1 10 0 1)
)

(script-fu-menu-register "script-fu-guide-repeat"
                         "<Image>/Image/Guides")

Simple Web Template

Using the code above, I am experimenting with basic templates for mocking up designs in GIMP, with guidelines.

960grid_leftnav.xcf