Resizing Images in AppleScript/Automator

I’ve already written a small Automator application that will resize an image to 640x480, but what about if I want to change it to a different size. There’s no way to set the resize amount on the fly in Automator, so I thought, it should be easy to do it in AppleScript. Except, for some reason, isn’t scriptable. I do have Image floating around (not sure if it’s a standard part of the system), which can do what I want.

 1     tell application "Finder"
 2     	set sels to selection
 3     end tell
 6     repeat with sel in sels
 7     	tell application "Image Events"
 8     		set img to open sel as alias
 9     		set dims to dimensions of img
10     	end tell
12     	set cursize to "Current Size of Image: " & (first item of dims as integer as text) & " x " & (last item of dims as integer as text)
14     	display dialog cursize
15     end repeat

This gets the current size, but I’m yet to find an easy way to get input from the user, and resize it according to this. I’m sure it can’t be that tricky!

blog comments powered by Disqus