User Tools

Site Tools


Sidebar


Site Information


Interactive Maps

Sidebar

scode:gimp:guides

Guides

Didn't take long. No option in Gimp to always show guides. So, I stole some code, made it do what I want. Not pretty, 'cause I hate Lisp (and all it's children), but a man gotta do what a man gotta do!

NOTE: It seems the scripts that are installed on Windows still have the *NIX line ending. I used gvim. Whatever you use, make sure you have the file type set to Unix.

Path: C:\Program Files\GIMP 2\share\gimp\2.0\scripts

Center Guides

;; -*-scheme-*-
 
;; Terrill Bennett 2019.  No copyright.  Public Domain.
;; Guides at 50% horizontal and vertical
 
(define (script-fu-guide-center-guide image drawable)
  (let* ((guide-id 0))
    (gimp-image-undo-group-start image)
 
    (set! guide-id (car (gimp-image-find-next-guide image 0)))
    (while (> guide-id 0)
      (gimp-image-delete-guide image guide-id)
      (set! guide-id (car (gimp-image-find-next-guide image 0)))
    )
 
    (gimp-image-undo-group-end image)
  )
 
  (let* (
        (hposition 0)
        (vposition 0)
        (width (car (gimp-image-width image)))
      	(height (car (gimp-image-height image)))
        )
 
		(set! hposition (/ (* height 50) 100))
		(set! vposition (/ (* width 50) 100))
 
		;; convert positions to pixelis
		(if (<= hposition height) (gimp-image-add-hguide image hposition))
		(if (<= vposition width) (gimp-image-add-vguide image vposition))
 
		(gimp-displays-flush)
  )
)
 
(script-fu-register "script-fu-guide-center-guide"
  "Center G_uide..."
  _"Add a guide at the position specified as a percentage of the image size"
  "Terrill Bennett"
  "Terrill Bennett, 2019"
  "April 2019"
  "*"
  SF-IMAGE      "Input Image"      0
  SF-DRAWABLE   "Input Drawable"   0
)
 
(script-fu-menu-register "script-fu-guide-center-guide"
                         "<Image>/Image")

Quarter Guides

;; -*-scheme-*-
 
;; Terrill Bennett 2019.  No copyright.  Public Domain.
;; Guides at 25%, 50% and 75% horizontal and vertical
 
(define (script-fu-guide-quarter-guide image drawable)
  (let* ((guide-id 0))
    (gimp-image-undo-group-start image)
 
    (set! guide-id (car (gimp-image-find-next-guide image 0)))
    (while (> guide-id 0)
      (gimp-image-delete-guide image guide-id)
      (set! guide-id (car (gimp-image-find-next-guide image 0)))
    )
 
    (gimp-image-undo-group-end image)
  )
 
  (let* (
        (hposition 0)
        (vposition 0)
        (width (car (gimp-image-width image)))
      	(height (car (gimp-image-height image)))
        )
 
		;; 75%
		(set! hposition (/ (* height 75) 100))
		(set! vposition (/ (* width 75) 100))
 
		;; convert positions to pixelis
		(if (<= hposition height) (gimp-image-add-hguide image hposition))
		(if (<= vposition width) (gimp-image-add-vguide image vposition))
 
		;; 50%
		(set! hposition (/ (* height 50) 100))
		(set! vposition (/ (* width 50) 100))
 
		;; convert positions to pixelis
		(if (<= hposition height) (gimp-image-add-hguide image hposition))
		(if (<= vposition width) (gimp-image-add-vguide image vposition))
 
		;; 25%
		(set! hposition (/ (* height 25) 100))
		(set! vposition (/ (* width 25) 100))
 
		;; convert positions to pixelis
		(if (<= hposition height) (gimp-image-add-hguide image hposition))
		(if (<= vposition width) (gimp-image-add-vguide image vposition))
 
		(gimp-displays-flush)
  )
)
 
(script-fu-register "script-fu-guide-quarter-guide"
  "Quarter Guide..."
  _"Add a guide at the position specified as a percentage of the image size"
  "Terrill Bennett"
  "Terrill Bennett, 2019"
  "April 2019"
  "*"
  SF-IMAGE      "Input Image"      0
  SF-DRAWABLE   "Input Drawable"   0
)
 
(script-fu-menu-register "script-fu-guide-quarter-guide"
                         "<Image>/Image")

Two-Thirds Guide

;; -*-scheme-*-
 
;; Terrill Bennett 2019.  No copyright.  Public Domain.
 
(define (script-fu-guide-thirds-guide image drawable)
  (let* ((guide-id 0))
    (gimp-image-undo-group-start image)
 
    (set! guide-id (car (gimp-image-find-next-guide image 0)))
    (while (> guide-id 0)
      (gimp-image-delete-guide image guide-id)
      (set! guide-id (car (gimp-image-find-next-guide image 0)))
    )
 
    (gimp-image-undo-group-end image)
  )
 
  (let* (
        (hposition 0)
        (vposition 0)
        (width (car (gimp-image-width image)))
      	(height (car (gimp-image-height image)))
        )
 
		;; 66%
		(set! hposition (/ (* height 66) 100))
		(set! vposition (/ (* width 66) 100))
 
		;; convert positions to pixelis
		(if (<= hposition height) (gimp-image-add-hguide image hposition))
		(if (<= vposition width) (gimp-image-add-vguide image vposition))
 
		;; 33%
		(set! hposition (/ (* height 33) 100))
		(set! vposition (/ (* width 33) 100))
 
		;; convert positions to pixelis
		(if (<= hposition height) (gimp-image-add-hguide image hposition))
		(if (<= vposition width) (gimp-image-add-vguide image vposition))
 
		(gimp-displays-flush)
  )
)
 
(script-fu-register "script-fu-guide-thirds-guide"
  "TwoThirds Guide..."
  _"Add a guide at the position specified as a percentage of the image size"
  "Terrill Bennett"
  "Terrill Bennett, 2019"
  "July 2019"
  "*"
  SF-IMAGE      "Input Image"      0
  SF-DRAWABLE   "Input Drawable"   0
)
 
(script-fu-menu-register "script-fu-guide-thirds-guide"
                         "<Image>/Image")
scode/gimp/guides.txt · Last modified: 2019/07/07 06:20 by terrill