08-11-2025, 02:21 PM
Here's the whole script
Code:
(define (script-fu-edge input-path output-path)
;(gimp-message "starting up")
;(gimp-message (string-append "path = " input-path))
(let* (
(filepaths (car (file-glob (string-append input-path "*.png") 1)))
(filename "")
(full_in_path "")
(full_out_path "")
);end of variable definitions in outer block
(while (not (null? filepaths))
(set! filename (substring (car filepaths) (string-length input-path) (string-length (car filepaths))))
;(gimp-message filename)
(set! full_in_path (string-append input-path filename))
(set! full_out_path (string-append output-path filename))
;(gimp-message (string-append "Input path = " full_in_path))
;(gimp-message (string-append "Output path = " full_out_path))
(set! filepaths (cdr filepaths))
(let* (
(image (car (file-png-load RUN-NONINTERACTIVE full_in_path full_in_path )))
(drawable (car (gimp-image-get-layers image)))
)
(gimp-image-convert-grayscale image)
(pdb-gimp-edge-detect drawable EDGE-DETECT-SOBEL 1 0)
(gimp-drawable-merge-new-filter
2 ; The drawable to apply the filter to
"gegl:edge" ; The name of the GEGL operation
0 ; The merge-mode (0 for normal)
LAYER-MODE-REPLACE ; The layer mode (e.g., replace, normal, etc.)
100.0 ; The opacity (0.0 to 100.0)
"amount" 2.0 ; Parameter: amount of edge detection
"border-behavior" "none" ; Parameter: how to handle image borders
"algorithm" "sobel" ; Parameter: the edge detection algorithm
)
(gimp-message (string-append "saving file " full_out_path))
(gimp-file-save RUN-NONINTERACTIVE image full_out_path full_out_path -1)
)
); end of while
); end of outer block
); end of function
(script-fu-register
"script-fu-edge" ;function name
"Edge Image" ;menu label
"Converts an image to edge Image\
and saves the result as a new file" ;description
"Peter McGuinness" ;author
"copyright 2025, Peter McGuinness" ;copyright notice
"August 6, 2025" ;date created
"*" ;image type that the script works on
SF-STRING "Input path" "/users/public/test/images/"
SF-STRING "Output path" "/users/public/test/edges/"
)
(script-fu-menu-register "script-fu-edge" "<Image>/Filters/Chameleon")