Gimp and scripts
I've always wanted to figure out how to run the gimp in batch mode. I wanted to be able to use the gimp "posterize" option because I found that it worked better than the option -posterize that comes with the Imagemagick package. The material that I was posterizing was scanned text. The files were 3 megs per file and all that was on these image files was mostly plain text. After the gimp posterizing process, the files went from ~3megs to ~100kb.
Turns out scripting in the gimp is fairly easy. I used the following link as a base for what I wanted to do:
http://www.gimp.org/tutorials/Basic_Batch/
and the following page to look at some syntax:
http://adrian.gimp.org/scripts/test.scm
In the following folder folder ~/.gimp-2.2/scripts I placed the file posterize.scm with the following contents:
(define (posterize filename posterfactor)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image))))
(gimp-message "gimp-posterize img layer" posterfactor)
(gimp-posterize drawable posterfactor)
(gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
(gimp-image-delete image)))
Then with one find command, I was able to posterize all ~400 files that I had in the folder that I was using.
find -iname '*.png' -exec gimp -i -b '(posterize "{}" 2)' '(gimp-quit 0)' ';'
After much processing time, I saved myself quite a bit of disk space.