Scripting graphics manipulations, improving speed over GraphicConverter 4
Scripting graphics manipulations, improving speed over GraphicConverter 4
- Subject: Scripting graphics manipulations, improving speed over GraphicConverter 4
- From: Jeremy Reichman <email@hidden>
- Date: Tue, 20 Mar 2001 18:17:04 -0500
I've got a largish script that I've written -- mostly to force myself to
make a complex AppleScript script and learn scripting -- that generates HTML
index pages and thumbnail previews from images. I think it's rather slick
considering I can't program well at all.
One of my main goals was to make something that I could reliably run every
night, so I could just drop images onto my Web server and have "magic
happen" before the next morning.
However, my script takes a loooong time to process the data (~1 GB of ~200
kb JPEGs). I'm talking hours, about 10 of them. I'm using two external
applications, along with Jon's Commands in places, to do the bulk of the
actual HTML- and preview-generation. BBEdit 5.1 and GraphicConverter suited
my needs when I was developing the script because they were relatively easy
to figure out and I'd already paid for both. Surely, my code isn't as
optimized as it could be (again, my AppleScripting skills are somewhere
between novice and intermediate, and this is a learning project), but I
suspect something else.
It appears that GraphicConverter is taking several seconds each time it
opens and does any work with an image. It visably opens the image in the
GUI, and I see each operation -- running in the background or foreground
(telling it to "activate") doesn't seem to make a difference. It may also
have a memory leak or something that is leading to instability after several
hundred MBs of files are processed. ("Geez, he's complaining about problems
after several hundred megs?!?" -- I am cataloging my own personal digital
camera work, and I have racked up nearly a GB's worth of images since 1996.
Fun to organize all that!)
Anyway, I'm considering replacing GC with something else -- anything else
that may be faster, really. I don't know if there's an OSAX or another app
out there (QuickTime?) that would just allow me to do the image processing
and/or manipulations for the thumbnail previews and the tags I need to
insert in the HTML file:
- find original horiz & vert resolution, to determine landscape vs.
portrait orientation and scaling factor for previews
- shrink/scale images, especially in a high quality way (I like GC's
quality for this)
- save scaled images to GIF or JPEG, stripped of resource forks to be
Web-friendly, with a specific file name and location (so as to not overwrite
the original file)
- "auto level" the original and preview images -- GC 4.04's "auto level"
scripting command does not work
I also need to be able to determine the names (alone) of the original and
preview images, but if push comes to shove, I can do that in the Finder
instead. (Right now, I'm pulling all of the internal information about the
file out from subroutine that calls GraphicConverter.)
That's mostly it. Anything that's cheap (I'm doing this myself) and fast and
scriptable will do at this point. I wish there were an OSAX that would let
me do this without opening the file in a full GUI program. (I have a friend
who has written a UNIX shell script that does pretty much the same thing in
about 1/10 the lines of code and that's so much faster that I'm just
aghast.) If there's a way to have a script process an image in GC without
opening it in the GUI, please let me know!
I will probably make this script available publicly at some point, too, if
anyone's interested. I've tried to write it so it wasn't terribly specific
to my setup.
Off-topic: Overall, I'm getting disenchanted with the speed of GC, even the
latest 4.04 version. Perhaps this is why I'm blaming GC for this scripting
slowness, rightly or wrongly. But the program itself doesn't seem any faster
on my dual G4/450 than my PB G3/400. The major UI functions I use are the
image browser and rotation contextual menu commands, and they are downright
pokier -- and get far worse when you access files over a LAN, as I'm doing
much of the time.
--
Jeremy Reichman, aka "Jaharmi"
Software Specialist III (Mac OS) / Instructor
Customer Support Services
Information and Technology Services
Rochester Institute of Technology
Rochester, New York, USA
World Wide Web <
http://www.rit.edu/~jjracc/>
Electronic mail <
mailto:email@hidden>