tell application "Finder" to set aFile to choose file
tell application "Image Events"
launch
set this_image to open aFile
scale this_image by factor 0.75
save this_image
close this_image
end tell
works perfectly. Why does it not work in ASOC ? The “open” message seems to be send to the Finder (preview opens the file in a window). And address the message to the image itself (tell this_image to scale by factor 0.75) gives and error (this_image does not understand the message “scale”)…
I copied and pasted your code into my applicationWillFinishLaunching method, and it worked fine – no error messages and the image was resized properly, so I’m not sure what is going on with your program. Was this code inside some other method?
Hello Ric, today is a Monday subtly disguised in Friday
It works now, I had forgotten “as alias” for the “open” message… (I also extracted the “launch” from the loop):
tell application “Image Events”
launch
repeat with theFile in fileList
if (size of theFile is greater than 100000) then
try
set this_image to open theFile as alias
scale this_image by factor 0.75
save this_image with compression level medium
close this_image
end try
end if
end repeat
end tell