Created
December 6, 2022 01:06
-
-
Save pohmelie/8e6842806ccf9bfc8f92d18e84f81748 to your computer and use it in GitHub Desktop.
«Text border» plugin for GIMP (put it to `~/.config/GIMP/{version}/scripts/`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(script-fu-register "script-fu-text-border" | |
"Text border..." | |
"Creates text border" | |
"Anon" | |
"Anon" | |
"2012" | |
"" | |
SF-IMAGE "Image" 0 | |
SF-DRAWABLE "Layer" 0 | |
SF-COLOR "Color" '(0 0 0) | |
SF-ADJUSTMENT "Width" '(5 1 45 2 5 1 0) | |
SF-TOGGLE "Auto width" TRUE | |
SF-VALUE "Auto width divider" "13" | |
) | |
(script-fu-menu-register "script-fu-text-border" | |
"<Image>/Filters") | |
(define (script-fu-text-border image layer color width auto-width auto-width-divider) | |
(let* ( | |
(foreground-color (car (gimp-context-get-foreground))) | |
(image-height (car (gimp-image-height image))) | |
(image-width (car (gimp-image-width image))) | |
(text-mode? (car (gimp-drawable-is-text-layer layer))) | |
(original-name (car (gimp-drawable-get-name layer))) | |
(border-layer) | |
) | |
(cond | |
((= text-mode? FALSE) | |
(gimp-message "Error: Active layer is not a text.") | |
) | |
(else | |
(gimp-undo-push-group-start image) | |
(if (= auto-width TRUE) | |
(set! width (/ (car (gimp-text-layer-get-font-size layer)) | |
auto-width-divider))) | |
(set! border-layer (car (gimp-layer-new image image-width image-height 1 "border" 100 0))) | |
(gimp-image-add-layer image border-layer -1) | |
(gimp-drawable-fill border-layer TRANSPARENT-FILL) | |
(gimp-selection-layer-alpha layer) | |
(gimp-selection-grow image width) | |
(gimp-context-set-foreground color) | |
(gimp-edit-fill border-layer FOREGROUND-FILL) | |
(gimp-context-set-foreground foreground-color) | |
(gimp-image-lower-layer image border-layer) | |
(set! layer (car (gimp-image-merge-down image layer EXPAND-AS-NECESSARY))) | |
(plug-in-autocrop-layer 1 image layer) | |
(gimp-drawable-set-name layer original-name) | |
(gimp-selection-none image) | |
(gimp-undo-push-group-end image) | |
(gimp-displays-flush))) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment