Skip to content

Instantly share code, notes, and snippets.

@cstrouse
Created October 25, 2012 16:11
Show Gist options
  • Select an option

  • Save cstrouse/3953724 to your computer and use it in GitHub Desktop.

Select an option

Save cstrouse/3953724 to your computer and use it in GitHub Desktop.
Resizes images so that the shortest side is 250px. Wrote this before the bash version but Finder crashed with the volume of images that had to be processed.
with timeout of (30 * 60) seconds
tell application "Finder"
set input_images to every document file of folder "Users:tzayad:Pictures:test" of startup disk whose name extension is "jpg" or name extension is "png"
end tell
tell application "Image Events"
launch
repeat with a from 1 to length of input_images
try
set img to open file ((item a of input_images) as string)
copy dimensions of img to {W, H}
if W is less than H then
set scale_l to ((H * 250) / W) + 1
set scale_l to round scale_l rounding as taught in school
else
set scale_l to ((W * 250) / H) + 1
set scale_l to round scale_l rounding as taught in school
end if
scale img to size scale_l
save img with icon
close img
on error errMsg
-- do nothing
end try
end repeat
end tell
end timeout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment