July 17th, 2005 | Published in old and busted
I did some reading this weekend about dealing with digital photos, most specifically the sizes they work best at if you want decent prints/reproductions down the line. The folks at Smugmug make a convincing argument for JPEGs at Photoshop quality level 8 as the best compromise between size and quality.
I did some experiments with a few pictures and my printer, thought a bit about The Future, and decided that, for most purposes, uploading images at Smugmug’s recommended quality equals a good tradeoff between quality and efficiency: grandparents can still make nice prints of Ben photos, there’s less wasted bandwidth, and if I’m making periodic DVD backups of the “originals,” then everything ought to be o.k.
The next problem, then, is how to downsample photos en masse before uploading them. There are some neat tools for iPhoto for uploading to Gallery or Flickr, but they only allow for resized images, not resampled ones. I want to keep the full-sized images … I also just want to up their compression enough to get the loss in file size.
Photoshop Elements can bulk process files, but it takes a while to launch and that’s not necessarily a shareable solution, because I don’t know too many people with copies of Elements.
So Automator and ImageMagick to the rescue.
I use the ImageMagick command “mogrify” to do the actual downsampling. A sample mogrify invocation looks like this:
mogrify -quality 80 sample_photo.jpg
I found a copy of ImageMagick binaries for OS X at Marc Liyanage’s site. After installing them, they’re located in /usr/local/bin.
The Automator action was pretty simple. You can grab a copy from my upload area.
The basic steps were:
Get Selected iPhoto items (that’s in the iPhoto area of Automator)
Copy the items to a given area (I put them in Photos/Downsampled) so we don’t mess with the originals.
Rename Finder Items. (I put a ‘d’ at the front of each filename so I know they’ve been downsampled if I ever come across them again somewhere in the filesystem).
Run Shell script. Automator makes this easy by providing a skeleton script into which you just have to plug the command you want run. The shell script is:
for f in "$@" do /usr/local/bin/mogrify -quality 80 "$f" done
And that’s about it for the simple version. I saved it as a Script Menu item.
The less simple version uses Fraser Speirs’ “Upload to flickr” Automator action to push the resulting downsamples to a Flickr account, but it’s still sort of “well, it worked once” and I don’t feel like getting into it until I know I did things the best way I could.
Automator is wonderful for 90 percent of a given workflow. It handles the part of programming I hate, but leaves an opening, so if I need to do something more involved than it knows how to do on its own, I can puzzle exactly that part out and drop it into the rest easily. It can require some kludginess now and then, but nothing horrible, and nothing you can’t clean up once a workflow executes successfully.
In just ten steps, even with some redundancy and kludginess built in, I’ve got an Automator workflow that copies files, renames them for clarity, operates on them with mogrify, squirts them up to Flickr, then dumps them in the trash. The originals are never touched, and if the workflow bombs at some point, there’s no question about which files that might be left around are redundant downsamples: they’ve been labelled as such.