
After making a whole bunch of thumbnail images for the member and mentor profiles on the Southwest Robotics site this past season, I finally decided last night to automate the process with a GIMP script, in preparation for next year’s new people.
So, what does it do? It takes the image it is run on, scales it (gimp-image-scale) to 120px x 90px, and utilizes script-fu-drop-shadow to add a correctly-positioned drop-shadow. (Correctly is, in this case, the same as all the other images I did manually.)
It’s a rather simple script; here’s the code:
; Script-Fu script to automatically
; resize and drop-shadow files for
; SWR profile shots
; IMPORTANT!
; Image must be EXACTLY 4:3 aspect
; ratio or it will be distorted.
; This script does not measure the
; image or do any cropping; it is
; up to you to crop the image properly.
(define (swr-make-profile-thumb img drawable)
(gimp-image-scale img 120 90)
(script-fu-drop-shadow img drawable 4 4 8 '(0 0 0) 80 TRUE)
)
(script-fu-register "swr-make-profile-thumb"
"Make SWR Profile Thumb"
"Scales the image to 120x90 and adds an appropriate drop-shadow"
"Voyagerfan5761"
"Voyagerfan5761"
"March 17, 2008"
"RGB*, GRAY*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Layer" 0)
(script-fu-menu-register "swr-make-profile-thumb"
"<Image>/Script-Fu/SWR")
Note: The original has my real name and an email address, but I have stripped them out for purposes of posting this in view of Web crawlers.
Input images must be in 4:3 aspect ratio to avoid distortion. I currently have no validation for aspect ratio, nor am I certain that it’s even possible to check such things, but if it is I will add it at some point. As can be seen from two of my updates last night on Twitter, I only just learned Script-Fu Scheme less than 10 hours ago.
The only real problem I had was developing the script-fu-drop-shadow line, which kept choking when I tried to set an interactivity mode. I eventually figured out that that parameter wasn’t required in 2.4 (or some other weird problem; I’m still not sure).
It’s obviously not much, just a few basic lines of the stripped-down Scheme that GIMP uses. Nevertheless, if you use my script as a base for a released script of your own, I would appreciate an acknowledgment. A link back here along the lines of, “Based on a short script by Voyagerfan5761” would be sufficient (note the link on “Voyagerfan5761”).
And of course, I’d appreciate any and all comments on this script, be they pointing out a better way to do things, something I missed, a suggestion for validating the aspect ratio (hey, it never hurts to ask). Or even a note that you based a script of your own off of mine. That’s highly unlikely, considering I didn’t even copy any code examples for this one. (OK, I lifted and modified the registration function from a GIMP tutorial page at GIMP‘s website, but that’s all.)