Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'An AppleScript to resize the longest side of an image' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to resize the longest side of an image
Authored by: microbians on Jan 01, '08 05:03:39AM
I think is better not to use Photoshop to do the resize when you have "Image Events" in the Mac Os X.

Here is a variation on the code found here ( but to handdle multiple files:

global theImage

tell application "Finder"
set sels to selection
end tell

set theResult to display dialog "Select the short side size." default answer "450"
set theAnswer to text returned of theResult
-- Retrieve the resize percentage amount
set theNewWidth to theAnswer as integer

repeat with sel in sels
set theImage to sel as alias

tell application "Finder"
set theImageName to name of theImage as string
set theImageFolder to (folder of theImage) as string
end tell

set theResizedImagePath to theImageFolder & theImageName & "_RESIZED" as string

tell application "Image Events"
set theImage to open theImage

-- This is the tricky part: you need to keep the ratio of the original picture
copy dimensions of theImage to {currentWidth, currentHeight}
set ratio to theNewWidth / currentWidth

tell theImage
scale by factor ratio to size theNewWidth
save in theResizedImagePath
end tell
end tell
end repeat

[ Reply to This | # ]