; alienator.scm is a GIMP plugin that runs through a series of image files ; defined by a regex pattern, then filters those files through GIMP's alien map ; function values and writes them out to a specified directory. Once the ; conversion is finished, the plugin closes GIMP. ; ; Usage: ; ; 1. Install to one of GIMP's plugin directories. ; 2. Run from command line or GIMP's Scheme interpreter: ; ; $ gimp -i -b='(alienator '/input/directory/*' '/output/directory') ; ts> (alienator '/input/directory/*' '/output/directory') ; ; 3. View the results and enjoy! ; ; Copyright (c) Andrew Marchetta 2019 ; ; This program 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 3 of the License, or ; (at your option) any later version. ; ; This program 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 this program. If not, see . ; ; define a function called alienator (define (alienator glob_pattern out_directory) ; seed the PRNG because we get consistently boring results otherwise (srand (car (gettimeofday))) ; load in the list and start iterating over it (define filelist (cadr (file-glob glob_pattern 0))) (while (not (null? filelist)) (define thisfile (car filelist)) (define thisfile_basename (car (reverse (strbreakup thisfile "/")))) (define thisfile_imgid (car (gimp-file-load RUN-NONINTERACTIVE thisfile thisfile))) (define thisfile_drawable (car (gimp-image-get-active-drawable thisfile_imgid))) (print (cons (cons "Working on file " thisfile) " ...")) ; generate some random values for our parameters (define red_freq_floor 0.500) (define red_freq_ceil 1.500) (define red_angle_floor 25.000) (define red_angle_ceil 45.000) (define green_freq_floor 0.500) (define green_freq_ceil 1.500) (define green_angle_floor 25.000) (define green_angle_ceil 45.000) (define blue_freq_floor 0.500) (define blue_freq_ceil 1.500) (define blue_angle_floor 25.000) (define blue_angle_ceil 45.000) (define red_freq (+ (/ (random (+ (* (- red_freq_ceil red_freq_floor) 1000) 1)) 1000) red_freq_floor)) (define green_freq (+ (/ (random (+ (* (- green_freq_ceil green_freq_floor) 1000) 1)) 1000) green_freq_floor)) (define blue_freq (+ (/ (random (+ (* (- blue_freq_ceil blue_freq_floor) 1000) 1)) 1000) blue_freq_floor)) (define red_angle (+ (/ (random (+ (* (- red_angle_ceil red_angle_floor) 10000) 1)) 10000) red_angle_floor)) (define green_angle (+ (/ (random (+ (* (- green_angle_ceil green_angle_floor) 10000) 1)) 10000) green_angle_floor)) (define blue_angle (+ (/ (random (+ (* (- blue_angle_ceil blue_angle_floor) 10000) 1)) 10000) blue_angle_floor)) ; let's alienate our image (plug-in-alienmap2 RUN-NONINTERACTIVE thisfile_imgid thisfile_drawable red_freq red_angle green_freq green_angle blue_freq blue_angle 0 1 1 1) ; write out a new image (define thisfile_newout (string-append out_directory (string-append "/" thisfile_basename))) (print (string-append "Writing to file " thisfile_newout)) (gimp-file-save RUN-NONINTERACTIVE thisfile_imgid thisfile_drawable thisfile_newout thisfile_newout) ; write a cute little log file (define logfile (open-output-file (string-append thisfile_newout "_alienated.log"))) (print (cons "Alienated " (cons thisfile "!")) logfile) (write-char #\newline logfile) (print (cons "Red frequency: " red_freq) logfile) (write-char #\newline logfile) (print (cons "Green frequency: " green_freq) logfile) (write-char #\newline logfile) (print (cons "Blue frequency: " blue_freq) logfile) (write-char #\newline logfile) (print (cons "Red angle: " red_angle) logfile) (write-char #\newline logfile) (print (cons "Green angle: " green_angle) logfile) (write-char #\newline logfile) (print (cons "Blue angle: " blue_angle) logfile) (write-char #\newline logfile) (close-output-port logfile) ; winnow down our list because that's how scheme does loops (set! filelist (cdr filelist)) ; close the while loop ) ; close the program (gimp-quit 0) ; close the define )