Skip to content

Instantly share code, notes, and snippets.

@oshenc
Last active May 7, 2017 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oshenc/5f0a8933df9c0f657cebe9cbe3aef791 to your computer and use it in GitHub Desktop.
Save oshenc/5f0a8933df9c0f657cebe9cbe3aef791 to your computer and use it in GitHub Desktop.
A batch for the gimp editor that makes scanned image perfect for me
;; ~/.gimp-2.8/scripts/perfectize.scm
;; usage: gimp -i -b '(batch-perfectize "*.jpg")' -b '(gimp-quit 0)'
define (batch-perfectize 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))))
(gimp-levels drawable 0 100 230 1.00 0 255)
(gimp-file-save RUN-NONINTERACTIVE
image drawable filename filename)
(gimp-image-delete image))
(set! filelist (cdr filelist)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment