-- preferences
property max_dimension : "1500"
property resolution_ppi : ""
property photoshop_option : "0"
property color_mode : ""
property flatten_option : "0"
on open draggeditems
repeat with currentFile in draggeditems
tell application "Image Events"
set drehZahl to 0
set currentImage to open currentFile
copy dimensions of currentImage to {currentWidth, currentHeight}
if max_dimension is not 0 then
if currentWidth is greater than currentHeight then
scale currentImage to size max_dimension
else
rotate currentImage to angle 90
scale currentImage to size max_dimension
set drehZahl to 1
end if
if drehZahl is 1 then
rotate currentImage to angle -90
end if
end if
save currentImage with icon
close currentImage
end tell
end repeat
quit
end open
i can’t figure it out with this script i sometimes get the error of “variable currentImage not defined” it seems to happen at at random intervals. this is just a snippet of the code. i would gladly post the entire xcode project.
any clues? what am i doing wrong
thanks.
Ken
My guess would be that currentFile
isn’t being opened (during the loop in which that error occurs).
i didn’t even think of that. do you have any recommendations as to how i could fix it?
thanks.
Ken
Hi Ken,
Image Events is a bit tricky to handle.
I suggest to add launch to run Image Events explicitly
and an error handler to release the current image properly
-- preferences
property max_dimension : "1500"
property resolution_ppi : ""
property photoshop_option : "0"
property color_mode : ""
property flatten_option : "0"
on open draggeditems
tell application "Image Events"
launch
repeat with currentFile in draggeditems
try
set drehZahl to 0
set currentImage to open currentFile
copy dimensions of currentImage to {currentWidth, currentHeight}
if max_dimension is not 0 then
if currentWidth is greater than currentHeight then
scale currentImage to size max_dimension
else
rotate currentImage to angle 90
scale currentImage to size max_dimension
set drehZahl to 1
end if
if drehZahl is 1 then
rotate currentImage to angle -90
end if
end if
save currentImage with icon
close currentImage
on error e
log e
try
close image 1
end try
end try
end repeat
end tell
quit
end open
stefan. that seems to have worked. thanks. i’ll post a link to to the actual app (which is more alpha than alpha)
thanks.
Ken
http://www.thebarricades.de/kenfrederick/?id=23
here’s the link to the app. it’s very alpha. and i’m hoping to get it to work without using photoshop. any bugs or suggestions let me know.
thanks.
Ken