I am trying to use the Preview>Rotate Image Automator Action to rotate images that have been stripped of their EXIF data by a resize action. I need a way to stop it from rotating the landscape images. I don’t have a lot of applescript experience so I am looking for some help to modify the Rotate Images Action, or use another action.
Thanks for your help,
David
Hello dcphotog,
Does this do what you need? Just place this AppleScript in the “Run AppleScript” action within your workflow.
on run {input, parameters}
if ((count of input) > 0) then
set theOutput to {} -- THIS LIST WILL CONTAIN ALL NON-LANDSCAPE IMAGES
repeat with i from 1 to count of input
set thisItem to item i of input
tell application "Finder"
if class of item 1 of input is document file then
set theImageAlias to (item i of input) as alias
tell application "Image Events"
launch
set theImage to open theImageAlias
set theProperties to properties of theImage
set theDimensions to dimensions of theProperties
-- theDimensions CONTAINS TWO NUMBERS - {pixelWidth, pixelHeight}
if (item 1 of theDimensions ≤ item 2 of theDimensions) then
set end of theOutput to theImageAlias
-- IF YOU WANT TO ROTATE THE NON-LANDSCAPE IMAGES HERE
-- AND THEN PASS ALL THE IMAGES BACK OUT OF THIS ACTION
-- UN-COMMENT THIS CODE AND UN-COMMENT THE RETURN VALUE
-- AT THE END OF THIS SCRIPT
--rotate theImage to angle 90 -- SPECIFY DEGREES OF ROTATION
--save theImage in theImageAlias -- SAVES OVER ORIGINAL
end if
close theImage
end tell -- application "Image Events"
end if -- class of item 1 of input is document file then
end tell -- application "Finder"
end repeat -- with i from 1 to count of input
end if
--return input -- THIS RETURNS ALL THE IMAGES THAT WERE ORIGINALLY PASSED IN
return theOutput -- THIS RETURNS ONLY THE NON-LANDSCAPE IMAGES
end run
end run
jON bEEBE