I have created a script (my first) which changes the colour of an image without affecting saturation (eg. blue becomes red, but grey remains grey). It works ok, except that the input GIF images become all-opaque. I didn't see any specific options on how to save a transparent GIF image. Any help? My script is below.
(define (recolour pattern hue-offset) (let* ((filelist (cadr (file-glob pattern 1)))) (while (not (null? filelist)) (let* ((filename (car filelist)) (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))) (if (not (= RGB (car (gimp-image-base-type image)))) (gimp-image-convert-rgb image)) (let*( (drawable (car (gimp-image-get-active-drawable image))) (red (car (gimp-layer-new image 2000 2000 0 "red" 100 11))) (final (gimp-image-flatten image)) ) (gimp-image-insert-layer image red 0 -1) (gimp-context-set-foreground '(255 0 0)) (gimp-drawable-fill red 0) (set! final (car (gimp-image-flatten image))) (gimp-image-convert-indexed image NO-DITHER MAKE-PALETTE 255 FALSE TRUE "") (gimp-file-save RUN-NONINTERACTIVE image final filename filename) (gimp-image-delete image)) (set! filelist (cdr filelist))))))