Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
gegl filters in batch processing
#3
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")
Reply


Messages In This Thread
gegl filters in batch processing - by pyjamaslug - 08-10-2025, 08:18 PM
RE: gegl filters in batch processing - by Ofnuts - 08-11-2025, 08:34 AM
RE: gegl filters in batch processing - by pyjamaslug - 08-11-2025, 02:21 PM
RE: gegl filters in batch processing - by teapot - 08-12-2025, 02:48 AM
RE: gegl filters in batch processing - by Ofnuts - 08-11-2025, 08:05 PM

Forum Jump: