;; -*-scheme-*- ;; guides-from-selection or selection-to-guides (define (script-fu-guides-from-selection image drawable) (let* ( (boundries (gimp-selection-bounds image)) ; non-empty INT32 TRUE if there is a selection (selection (car boundries)) (x1 (cadr boundries)) (y1 (caddr boundries)) (x2 (cadr (cddr boundries))) (y2 (caddr (cddr boundries))) ) ;; need to check for a selection or we get guides right at edges of the image (if (= selection TRUE) (begin ;; only need undo if we do do something (gimp-image-undo-group-start image) (gimp-image-add-vguide image x1) (gimp-image-add-hguide image y1) (gimp-image-add-vguide image x2) (gimp-image-add-hguide image y2) (gimp-image-undo-group-end image) (gimp-displays-flush) ) ;; else. dont annoy users with to many error messages ;(gimp-message _"Selection not found. ") ) ) ) ;; Do not want to clutter View or Select menus for a minority feature, but anyway... ;(set! menu-item _"/Select/Guides from Selection") (set! menu-item _"/View/Guides from Selection") ;; the Guides related Perl scripts in version 1.2 put things here ;(set! menu-item _"/Guides/Guides from Selection") ;; put it out of the way under Script-fu for lack of a better idea ;(set! menu-item _"/Script-Fu/Guides/Guides from Selection") ;(set! menu-item _"/Script-Fu/Utils/Guides from Selection") (script-fu-register "script-fu-guides-from-selection" ;; menu-item _"/View/Guides from Selection" _"Creates four Guides around the bounding box of the current selection. This script can be useful when used with 'Transform, Guillotine' (or 'Web, Slice Image'). It makes it easier to quickly isolate parts of an image that contain important details such as text, that you might want to save at a higher quality or using a differnt type of image format. " "Alan Horkan. " ; author(s) "Alan Horkan, 2004. Dedicated to the Public Domain. " ; rights "2004 08 13 UTC" ; date, Friday 13th wooo, spookey! "" ; works with all image types SF-IMAGE "Image" 0 SF-DRAWABLE "Drawable" 0 ) ;; came up with the idea, early in the week. ;; started and got it working very quickly on Friday 13th. ;; Saturday 14th did some cleanup, nice indentation, error handling, comments ;; and rewrote it not to need gimp-selection-is-empty