Bilder klein rechnen mit AppleScript
by hubi on 26/11/2008on open some_items
tell me to activate
display dialog "Längste Seite" default answer "1024"
set mh to (text returned of the result) as integer
repeat with this_item in some_items
try
rescale_and_save(this_item, mh)
end try
end repeat
end open
to rescale_and_save(this_item, target_width)
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_width is greater than current_height then
scale this_image to size target_width
else
-- figure out new height
-- y2 = (y1 * x2) / x1
set the new_height to (current_height * target_width) / current_width
scale this_image to size new_height
end if
tell application "Finder" to set new_item to ¬
(container of this_item as string) & "scaled." & (name of this_item)
save this_image in new_item as typ
end tell
end rescale_and_save
There is 1 comment in this article: