Skip to content

Instantly share code, notes, and snippets.

@ddbuscombe
Created July 26, 2013 02:57
Show Gist options
  • Select an option

  • Save ddbuscombe/6085758 to your computer and use it in GitHub Desktop.

Select an option

Save ddbuscombe/6085758 to your computer and use it in GitHub Desktop.
Batch GIMP script for auto-sharpen, white-balance and colour enhance
(define (batch-auto-fix pattern
radius
amount
threshold)
(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))))
(plug-in-unsharp-mask RUN-NONINTERACTIVE
image drawable radius amount threshold)
(gimp-levels-stretch drawable)
(plug-in-color-enhance RUN-NONINTERACTIVE
image drawable)
(gimp-file-save RUN-NONINTERACTIVE
image drawable filename filename)
(gimp-image-delete image))
(set! filelist (cdr filelist)))))
@febs

febs commented May 18, 2016

Copy link
Copy Markdown

Ehy, how do you use this? Thanks :)

@JLuc

JLuc commented Jan 24, 2017

Copy link
Copy Markdown

Save as batch-unsharp.scm in your gimp script folder (could be ~/.gimp-2.8/scripts)
Run with
gimp -i -b '(batch-unsharp-mask "*.tif" 5.0 0.5 0)' -b '(gimp-quit 0)'

See https://www.gimp.org/tutorials/Basic_Batch/ for more explanation

@RenBS

RenBS commented Oct 21, 2017

Copy link
Copy Markdown

Running with this command I got an unbound variable error message. Changing the "batch-auto-fix" in the first line of the script to "batch-unsharp-mask" solved it.

@kikislater

kikislater commented Jul 19, 2018

Copy link
Copy Markdown

How to use it in gimp 2.10 ? What is new directory of ~/.gimp-2.8/scripts
Edit : Found in Edit->Preferences->Folders->Scripts

@mrniko31

mrniko31 commented Jan 4, 2019

Copy link
Copy Markdown

Run with
gimp -i -b '(batch-auto-fix "*.jpg" 5.0 0.5 0)' -b '(gimp-quit 0)'

@Kostanos

Copy link
Copy Markdown

What this numbers - 5.0 0.5 0 stand for? I mean, where can I found some info about how to use/change them?
Thank you.

@ckolluru

ckolluru commented Feb 27, 2020

Copy link
Copy Markdown

Those are the default values for radius, amount and threshold. More info here:

https://docs.gimp.org/2.6/en/plug-in-unsharp-mask.html

@ckolluru

ckolluru commented Feb 28, 2020

Copy link
Copy Markdown

Gimp is trying to look for files named 5.0 0.5 and 0 when I run this command. I'm using GIMP 2.8

Is there a fix for this issue?

EDIT: figured it out. if on windows you will use double quotes everywhere, " instead of " and \ instead of \ so that the escape characters make sense.

"C:\Program Files\GIMP 2.10\bin\gimp-console-2.10.exe" -b "(process-fingerprint "C:\Users\paynekj\Pictures\tmp\output1.jpg")" -b "(gimp-quit 0)"

@zeddock

zeddock commented Jul 25, 2020

Copy link
Copy Markdown

Hit an error.
Hope this helps

gimp -i -b '(batch-auto-fix "*.jpg" 5.0 0.5 0)' -b '(gimp-quit 0)'

Plug-in "dbp"
(/usr/lib/gimp/2.0/plug-ins/dbp) is installing procedure "extension-dbp" with a full menu path "/Xtns/Batch Process..." as menu label, this deprecated and will be an error in GIMP 3.0
batch command experienced an execution error:
Error: eval: unbound variable: batch-auto-fix

@ckolluru

ckolluru commented Jul 25, 2020

Copy link
Copy Markdown

Did you copy the script batch-auto-fix to the scripts folder in your installation of GIMP? Then you can run it by first navigating to the folder containing the script in command prompt, adding the gimp executable to your system PATH variable and then specifying the full directory path to your images in your command.

@lamanawebu

Copy link
Copy Markdown

Run with
gimp -i -b '(batch-auto-fix "*.jpg" 5.0 0.5 0)' -b '(gimp-quit 0)'

and under Windows you have to change it to
gimp -i -b "(batch-auto-fix """*.jpg""" 5.0 0.5 0)" -b "(gimp-quit 0)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment