Handy Image Dimensions Applescript
09/18/13 02:49 PM
As I prepare AlphaTalk for iOS7, there are all of these new sizes of icon files that I need to support. I wanted to easily see what sizes I already had (as my file names aren’t always that helpful). I thought it would be nice to see the image dimensions in list view in the Finder. So, here’s an Applescript that can be used as a service to put an image file’s dimensions into the Comments field of the file. It wipes out any other comments that are there, so beware if you were using the comments field for something interesting. In Automator, you can just create a new service, have it only accept image files, and then have it run this AppleScript. Hope this works for you!
on run {input}
set theList to the input
repeat with x from 1 to the count of items in theList
set theFile to (item x of theList) as alias
tell application "Image Events"
launch
set this_image to open theFile
copy the dimensions of this_image to {xdim, ydim}
close this_image
end tell
tell application "Finder"
set theName to the name of (item x of theList)
set commento to (xdim as string) & "x" & (ydim as string)
set comment of theFile to commento
end tell
end repeat
end run
on run {input}
set theList to the input
repeat with x from 1 to the count of items in theList
set theFile to (item x of theList) as alias
tell application "Image Events"
launch
set this_image to open theFile
copy the dimensions of this_image to {xdim, ydim}
close this_image
end tell
tell application "Finder"
set theName to the name of (item x of theList)
set commento to (xdim as string) & "x" & (ydim as string)
set comment of theFile to commento
end tell
end repeat
end run