Using Applescript to batch resize images

A couple of months ago, I wanted to try and collate a lot of my cloud accounts and reduce the number of services that I was using for various tasks. Part of it was to move my photos from Picasa to Dropbox which was a pretty daunting task given the number of photos I had and especially with the slow upload speeds we have in England.

It now isn’t uncommon to buy a smartphone with a 5, 8 or even 12 megapixel camera which leads to photos being several MB at the very least. Personally, I didn’t need my photos to stay in such a large resolution as I am not a professional photographer nor was I intending to have them blown up and printed. At most, my photos had to be at least 1080p which is enough to show friends and family on a computer or phone/tablet screen (I also didn’t want to wait several minutes for each photo to download if I was browsing them on the cloud).

After a quick resizing test, reducing the resolution to 1080p brought the file size down to about 0.5MB on average which was a huge improvement and started to look for software to do a batch resize.

Only problem was that I couldn’t find anything for the Mac that would be able to handle directories of photos in different orientations and skip photos that were already smaller then 1080p. A few results pointed me in the direction of using AppleScript and although I hadn’t scripted in it before, I thought I give it a try given how powerful it is for automation.

Personally, I wasn’t a big fan of the syntax and found my muscle memory for operators kept going to usual keys used in most languages which was a little frustrating. e.g logical OR is the word ‘or’ instead of ‘||’. However, I had no problem creating a script quickly to mass resize photos and most questions were a Google search away. The only issue I had was the script timing out and after a little bit of debugging, I found out this was only happening on large folders and I had to override the default timeout value.

Below is a link to the script and as usual, it is supplied as is with no guarantee. I recommend trying a sample copy of photos to see if it would suit your needs. 

Tagged , , ,

2 thoughts on “Using Applescript to batch resize images

  1. KiwiCloudNinja says:

    This was a helpful script except the unicode characters in the source created some issues. I removed all the scale calculation code and replaced it with a simple “scale this_image by factor 0.5” which did what I wanted/needed.

  2. yaustar says:

    Strange about the unicode in the BitBucket Repo. Locally I have a ‘À’ as a ‘¬’, not sure what is happening there :/

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: