Bilder klein rechnen mit AppleScript

26/11/2008
Ich habe schon länge nach eine Lösung gesucht, wie ich schnell und einfach Bild für das Internet klein rechnen könnte. Die Tools, die das bisher konnten, waren aber nicht immer kostenlos oder umständlich. Seit 10.4 denke oder doch ehr 10.5 gibt es aber die ImageEvents für Apple
}und damit kann man recht einfach Bild klein rechnen. Das hier gezeigte Skript (Droplet, d.h. man zieht die Bilder einfach auf eine Programm-Version des Skriptes) habe ich in einem Forum-Beitrag bei macscripter.net gefunden. Sehr praktisch und nun fest in meinem Dock =)

on 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

1 Comment