(gimp-image-set-filename image filename) set gimps filename to reflect the file as saved (gimp-image-detach-parasite image "jpeg-settings") (gimp-image-detach-parasite image "exif-data") (gimp-image-detach-parasite image "gimp-metadata") lifted from gimp-save-for-web on github these are intended to remove the exif info and file save settings before saving (set! filename (string-append dir_name filename (number->string filenumber) ".jpg")) set filename to dir_name + filename + filenumber (number converted to string) + ".jpg" (set! comment "resized to 1080x1435")) and comment is resized to 1080x1435 (set! comment "resized to 1024x1024")) and comment is resized to 1024x1024 (set! dir_name "Desktop/") and dir_name is users desktop (comment "") define variable comment for save proceedure (filenumber adjustment_number) define variable filenumber for save proceedure abd set to adjustment_number (filename) define variable filename for save proceedure (dir_name) define variable dir_name for save proceedure (drawable (car (gimp-image-get-active-drawable image))) drawable has changed so this finds the drawable layer that is needed for file-web-export (gimp-image-undo-group-end image) end an undo group
(gimp-image-flatten image) flatten image alpha to background colour
(gimp-image-resize image targetwidth targetheight (/ (- targetwidth width) 2) (/ (- targetheight height) 2)) resize canvas to targetwidth by targetheight with offsets centered (set! height (car (gimp-image-height image))) (set! width (car (gimp-image-width image))) reset width and height to new dimensions (gimp-image-scale image (/ width (/ height targetheight)) targetheight) else scale to. (gimp-image-scale image targetwidth (/ height (/ width targetwidth))) then scale image to width targetwidth by new height (divide height by ratio of width divided by targetwidth) (set! targetheight 1080)) if option_size is 1 (1080x1435) set targetheight to 1435 ((= option_size 1) (set! targetwidth 1435) if option_size is 1 (1080x1435) set targetwidth to 1435 (set! targetheight 1024)) if option_size is 0 (1024x1024) set targetheight to 1024 (cond ((= option_size 0) (set! targetwidth 1024) if option_size is 0 (1024x1024) set targetwidth to 1024 (gimp-context-swap-colors) swops the foreground / background colours (gimp-context-set-default-colors) sets the foreground / backgroud colours to default (black / white) (gimp-context-set-interpolation 2) sets the interpolation method to (2) cubic (gimp-image-undo-group-start image) start an undo group for the image (targetheight) a variable for the target height dependant on option_size (targetwidth) a variable for the target width dependant on option_size (height (car (gimp-image-height image))) use start of gimps image height variable (width (car (gimp-image-width image))) use start of gimps image width variable (define (script-fu-dmkonlinux-web-image2 image define function and parameters in order of SF statements at end ie SF-IMAGE=image SF-DRAWABLE=drawable add ability to resize 1080 by 1435, 75% quality sRGB optomised, progressive, baseline, strip exif for "1080by1435 x.jpg" resizes files larger than 1024 by 1024 to 1024 pixels on the longest side then applies a black canvas to create a 1024 by 1024 pixel square image for "1024by1024 x.jpg" Resize the canvas to target width by target height with offsets centered.Alternatively target height by original width x (original height / target height). If the input image width is greater than the height, scale the image to the target width by original height x (original width / target width).Even so this ran to just over a hundred lines of code. I didn't fully automate it though as I was only doing five pictures at a time and I am very much a self taught beginner at coding. I used gimp and a scheme script to make the process easier as this variation in input size and ratio made the process a pain. I did something similar in order to create pictures that were of exactly the same dimensions for a html slideshow, even if the original file had been cropped, or was portrait or landscape in orientation.