-- Created by Mike Rapin -- -- drag files to the icon in Finder -- on open some_items set the height to 800 repeat with this_item in some_items try rescale_and_save(this_item, height) end try end repeat end open to rescale_and_save(this_item, target_height) tell application "Image Events" launch -- open the image file set this_image to open this_item set typ to this_image's file type copy dimensions of this_image to {current_width, current_height} if current_height is greater than current_width then scale this_image to size target_height else -- figure out new height -- y2 = (y1 * x2) / x1 set the new_height to (current_width * target_height) / current_height scale this_image to size new_height end if tell application "Finder" set new_item to ¬ (container of this_item as string) & "scaled." & (name of this_item) save this_image in new_item as typ delete this_item end tell end tell end rescale_and_save