I'm going to try to keep this short but I wanted to make a note of a quick script I just did to desaturate and lighten a bunch of images in the Gimp. The workflow I used was basically to open a bunch of images then do exactly the same thing to each one of them then close and save each one. My first thought was that clicking Tools->Colour Tools->Hue Saturation... then doing an adjustment & hitting Okay was taking too long. I knew I'd been here before so I dug out the script I did before to do Hue Rotation in the Gimp. I remember that painful learning curve to figure out Scheme. Luckily this time I want to use roughly the same command but I want to leave the hue alone and change the other two parameters. So I modified the code and pasted this in to the Script-Fu console.
gimp-file-save. I wanted to save and close each file after it was processed. I can't see a way to close files but
gimp-file-savewill save them. It wants the file name as a parameter. Maybe I could leave it blank or something but I don't know. I just looked up a function to get te existing file name since all my images already had names. That's what the
(car (gimp-image-get-filename image))does. It gets the file name as a string. So this script processes the image and saves it but the * remains in the title and when you close it the Gimp will ask if you want to save. I just use alt-F4 to close the window then alt-N to answer the save question ("Don't Save"). This isn't optimal but it's quick.
This little script was nice, after pasting it in to the Script-Fu console, all I had to do was use the line
(script-fu-adjust 70) to process and save the image with the -70.0 as part of the name in the title bar. I wasn't satisfied or the script would get my work done too fast or something because I decided I wanted to process all the images in just one script. The thing is Scheme is a functional language and doesn't like loops. Instead they're all about recursion. I don't want to fight to make the language do something it doesn't want to do so I tried to write something that did the job recursively. Something was wrong with my code though and the error messages were useless.
In the end I found a little example on Wikipedia that computes the Fibonnacci Sum for a number:.
I modified it until it handled my job:
It looks quite similar to the code I wrote on my own except that it works. After pasting this script in to the Script-Fu console, my workflow went like this:
(quicky 98 112)in the Script-Fu console.
It took a while to figure out, but my previous efforts helped me out so much that I think this one will come in handy again one day.