Irrational Exuberance!

Using Automator to Scale Images Horizontally

September 22, 2008. Filed under os-x

One of the problems with my old site design was that I used CSS to scale all the images to the right size, instead of making sure they actually fit well. I wanted to get away from that, and took all that CSS out.

But I still had the fundamental problem: the images weren't properly scaled. My first approach to solving this problem was to use the Python Imaging Library, PIL.

Unfortunately, PIL often doesn't detect the jpeg encoder library if you use precompiled versions. Neither my OSX laptop nor my Ubuntu server were able to handle jpegs without recompiling the source.

Because I wanted to go to bed, I wasn't really mentally up for much more thinking. Fortunately, the Automator and its point-and-click goodness came to my rescue.

A picture of an Automator workflow for horizontally scaling images.

Although Automator can scale images by default, it only scales them vertically, which wasn't what I wanted. After staring at it for a few moments I hatched my devious (by which I mean, inevitable) plan: rotate the images 90 degrees, scale them vertically, and then rotate them -90 degrees.

Although something certainly feels wrong that this actually works, it does work, amazingly well. Well enough to create a workflow named Size-For-Blog and leave it on my desktop.

Until this point I had ignored Automator, because I have faint memories of using AppleScript to make an icon that looked like the Harddrive run a shut down script when I was in sixth grade, and assumed it would be similarly useful.

But, hey, it's pretty helpful. I'm not sure if it'll be that helpful for my daily tasks, but from now on I'll at least check to see whether that is the case.