; batch-lab-colorboost.scm ; ; Version 0.1 October 2007 ; ; ; batch-lab-colorboost implements the color boost idea here: ; http://www.dslreports.com/forum/remark,15173919 ; It also applies the unsharp mask to the image before saving ; .xcf and .jpg versions of the image. ; ; This file should be put into your GIMP scripts directory. Probably ; something like ~/.gimp/scripts or ~/.gimp-2.2/scripts (this is where ; mine is--I'm on Debian Lenny/Sid). ; ; Usage: ; gimp -i -b '(batch-lab-colorboost "PATTERN" RADIUS AMOUNT THRESHOLD OPACITY)' '(gimp-quit 0)' ; ; Radius, Amount & Threshold refer to unsharp mask settings. ; Opacity sets opacity of new layer created by lab process. ; ; Example: ; gimp -i -b '(batch-brp-process "*.ppm" 5.0 0.5 0 30)' '(gimp-quit 0)' ; ;############################################################################## ; ; LICENSE ; ; Copyright (C) 2007 Ben Rasmussen ; ; batch-lab-colorboost is free software; you can redistribute it and/or ; modify it under the terms of the GNU General Public License as ; published by the Free Software Foundation; either version 2, or (at ; your option) any later version. ; ; batch-lab-colorboost is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ; General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with batch-lab-colorboost; see the file COPYING. If not, write to ; the Free Software Foundation, Inc., 51 Franklin Street, Fifth ; Floor, Boston, MA 02110-1301, USA. ; ;############################################################################## (define (batch-lab-colorboost pattern radius amount threshold opacity ) (let* ( (filelist (cadr (file-glob pattern 1))) (jpgname) (xcfname) (filename) (image) (drawable) ) (while filelist (set! filename (car filelist)) (set! image (car (gimp-file-load RUN-NONINTERACTIVE filename filename))) (set! drawable (car (gimp-image-get-active-layer image))) ;decompose to new lab image (set! labimage (car (plug-in-decompose RUN-NONINTERACTIVE image drawable "LAB" 1))) ;create array of layers (set! lablayers (gimp-image-get-layers labimage)) (set! b_layer (aref (cadr lablayers) 0)) (set! a_layer (aref (cadr lablayers) 1)) (set! l_layer (aref (cadr lablayers) 2)) ;dupe layer 'B', set to overlay and merge down (gimp-image-set-active-layer labimage b_layer) (set! copy (car (gimp-layer-copy b_layer 1))) (set! newlayer (car (gimp-image-add-layer labimage copy -1))) (set! drawable (car (gimp-image-get-active-layer labimage))) (gimp-layer-set-mode drawable 5) (gimp-image-merge-down labimage drawable 0) ;dupe layer 'A', set to overlay and merge down (gimp-image-set-active-layer labimage a_layer) (set! copy (car (gimp-layer-copy a_layer 1))) (set! newlayer (car (gimp-image-add-layer labimage copy -1))) (set! drawable (car (gimp-image-get-active-layer labimage))) (gimp-layer-set-mode drawable 5) (gimp-image-merge-down labimage drawable 0) ;merging changes layer id, so reset (set! lablayers (gimp-image-get-layers labimage)) (set! b_layer (aref (cadr lablayers) 0)) (set! a_layer (aref (cadr lablayers) 1)) (set! l_layer (aref (cadr lablayers) 2)) ;compose to new image (set! composeimage (car (plug-in-drawable-compose 1 labimage l_layer a_layer b_layer drawable "LAB"))) ;copy composed image to new layer on original image (set! drawable (car (gimp-image-get-active-layer composeimage))) (set! copy (car (gimp-layer-new-from-drawable drawable image))) (set! newlayer (car (gimp-image-add-layer image copy -1))) ;clean up tmp images (gimp-image-delete labimage) (gimp-image-delete composeimage) (set! drawable (car (gimp-image-get-active-layer image))) (gimp-layer-set-opacity drawable opacity) (set! jpgname (strbreakup filename ".")) (set! jpgname (unbreakupstr (butlast jpgname "."))) (set! xcfname (string-append jpgname ".xcf")) (set! jpgname (string-append jpgname ".jpg")) (gimp-file-save RUN-NONINTERACTIVE image drawable xcfname xcfname) (set! drawable (car (gimp-image-flatten image))) (plug-in-unsharp-mask RUN-NONINTERACTIVE image drawable radius amount threshold) (file-jpeg-save RUN-NONINTERACTIVE image drawable jpgname jpgname 1 0 1 0 "Ben Rasmussen Photography" 2 0 0 2) (gimp-image-delete image) (set! filelist (cdr filelist)) ) ) )