(define (e-ink-ize aimage adrawable scale awidth aheight colors) (let* ((aspect (/ awidth aheight)) (image (car (gimp-drawable-get-image adrawable))) (image-aspect 0)) (if (> (car (gimp-image-width image)) (car (gimp-image-height image))) (gimp-image-rotate image ROTATE-90)) (set! image-aspect (/ (car (gimp-image-width image)) (car (gimp-image-height image)))) (if (= (car (gimp-drawable-is-gray adrawable)) FALSE) (gimp-image-convert-grayscale image)) (if (= scale TRUE) (if (> image-aspect aspect) (gimp-image-scale image awidth (/ awidth image-aspect)) (gimp-image-scale image (* aheight image-aspect) aheight))) (gimp-image-convert-indexed image FS-DITHER MAKE-PALETTE colors TRUE TRUE "") )) (define (e-ink-ize-file filename ofilename scale awidth aheight colors) (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename))) (drawable (car (gimp-image-get-active-layer image)))) (e-ink-ize image drawable scale awidth aheight colors) (gimp-file-save RUN-NONINTERACTIVE image drawable ofilename ofilename) (gimp-image-delete image) )) (script-fu-register "e-ink-ize" _"/Script-Fu/E-ink-ize" "Converts an image to the best format for a defined E-ink display" "Chris Lord " "Chris Lord" "May 2008" "*" SF-IMAGE "Input image" 0 SF-DRAWABLE "Input drawable" 0 SF-TOGGLE "Scale" FALSE SF-VALUE "Width" "584" SF-VALUE "Height" "754" SF-VALUE "Colors" "8") (script-fu-register "e-ink-ize-file" _"/Xtns/Script-Fu/E-ink-ize file" "Converts an image to the best format for a defined E-ink display" "Chris Lord " "Chris Lord" "May 2008" "*" SF-FILENAME "Input file" "in.png" SF-VALUE "Output file" "out.png" SF-TOGGLE "Scale" FALSE SF-VALUE "Width" "584" SF-VALUE "Height" "754" SF-VALUE "Colors" "8")