Make it pop
For one my my recent Subscriber Crowns I had the need to quickly ‘enhance’ some images for a slideshow- make them a bit more vibrant. Something like the following:
I had 25 images to go through so doing each manually would have been a tedious waste of time. My two options for doing the enhancements that I wanted — saturation, contrast and brightness, and sharpening — were GIMP and imagemagick. I’ve used both for many years so either would have sufficed. I went for GIMP as I tried out the enhancements manually on one image so I knew what I was aiming for.
Thankfully, GIMP has a useful tutorial for its batch mode, called ‘GIMP Batch Mode’. I should probably go for obvious, descriptive names myself more often.
it mentions one of the important parts of any batch process, which is to be able to operate on a (globbed) file list:
You might want to apply an effect to a number of files, typically to a set of files in the same directory. GIMP 2.2 added a very useful function for this purpose, the file-glob plug-in. This turns GIMP into a versatile batch processor.
Gib Teh Codes
Since you asked so nicely, here’s what I went with in end. Bonus version for using with GIMP session, comments afterwards:
; satcontrsharp -- give image a little 'pop' (define (script-fu-satcontrsharp image drawable) (gimp-image-undo-group-start image) (gimp-drawable-hue-saturation drawable 0 0 0 50 0) (gimp-drawable-brightness-contrast drawable 0.039 0.051) (plug-in-unsharp-mask RUN-NONINTERACTIVE image drawable 3 0.5 0) (gimp-image-undo-group-end image) (gimp-displays-flush)) (define (batch-satcontrsharp pattern) (let* ((filelist (cadr (file-glob pattern 1)))) (while (not (null? filelist)) (let* ((filename (car filelist)) (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename))) (drawable (car (gimp-image-get-active-layer image)))) (script-fu-satcontrsharp image drawable) (gimp-file-save RUN-NONINTERACTIVE image drawable filename filename) (gimp-image-delete image)) (set! filelist (cdr filelist))))) (script-fu-register "script-fu-satcontrsharp" "Saturation-Contrast-Sharpness" "Enhances image by boosting saturation, brightness+contrast and sharpness" "bertieb" "bertieb" "2022-02-27" "RGB*" SF-IMAGE "Image" 0 SF-DRAWABLE "Drawable" 0) (script-fu-menu-register "script-fu-satcontrsharp" "<Image>/Filters/RH")
- the first
definesets up the common function which we can call from the batch version, or GIMP GUI
- the second is our batch function, based off the example given in the tutorial
script-fu-registeris needed to make the function available from GIMP GUI
- you can at present register straight to a menu entry but that is deprecated and will be an error in 3.0
- I found out through trial and error that omitting the seventh parameter — types of images the script works on — prevents you quickly re-running the script via
Ctrl+F(rerun last filter with the same settings)
- the last
script-fu-menu-registerregisters a menu entry; I popped this one in a submenu under filters with some other filters I have written (in python)
- this could be improved in a few ways- one enhancement I’ll probably do is to add different levels of enhancement, eg ‘weak/medium/strong’