07-31-2018, 08:11 PM
Hello all! First post here so I hope this make sense.
I am trying to resize images to the highest multiple of 4 (unless it already is a multiple of 4).
My script runs without any errors but does absolutely nothing to the images in the directory.
I tested out individual elements of the script in the GIMP console (or whatever it is called) and the ones I could test work fine.
I feel like I'm missing something simple.
Any ideas? The script is below.
I am trying to resize images to the highest multiple of 4 (unless it already is a multiple of 4).
My script runs without any errors but does absolutely nothing to the images in the directory.
I tested out individual elements of the script in the GIMP console (or whatever it is called) and the ones I could test work fine.
I feel like I'm missing something simple.
Any ideas? The script is below.
Code:
; example pattern form because it starts in C: "/Users/Etc/*.png"
(script-fu-register
"script-fu-resize-4" ;func name
"Resize To Multiple Of 4" ;menu label
"Rounds Canvas Size To Nearest Multiple Of 4" ;description
"Me" ;author
"copyright 2018, Me" ;copyright notice
"May 30, 2018" ;date created
"" ;image type that the script works on
SF-STRING "Folder Pattern" "/*.png"
)
(script-fu-menu-register "script-fu-resize-4" "<Image>/File")
(define (script-fu-resize-4 pattern)
(let*
(
(filelist (cadr (file-glob pattern 1)))
)
(while (not (null? filelist))
(let*
( ; variables
(filename (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)) )
(drawable (car (gimp-image-get-active-layer image)) )
(width (car (gimp-image-width image)) )
(height (car (gimp-image-height image)) )
)
; statements
(set! width (* 4 (ceiling (/ width 4))) )
(set! height (* 4 (ceiling (/ height 4))) )
(set! width (inexact->exact width) )
(set! height (inexact->exact height) )
(gimp-image-resize image width height 0 0)
(gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
(gimp-image-delete image)
)
;move to next file in folder
(set! filelist (cdr filelist))
)
)
)