Automator action "Rotate Images" is incredibly memory-intensive
I'm building an automator workflow to rotate images. It seems that sips
and other image rotation possibilities do not actually change the bits of the image, but just flip a switch for orientation, and I need to change the image bits. Anyway, I'm building the workflow using the "Rotate Images" action and it seems like it uses a ton of memory when you rotate multiple images (which is kind of the point of an automator action). Apparently, after it rotates an image, it retains the memory and only releases it after the entire action is complete. And so I end up running out of ram and also swap!
Is there a solution to force it to release memory?
Here is the some applescript code I wrote to rotate an image right 90. You may only rotate right. So if you want to rotate left 90 to enter you will have to rotate right 270.
(*
Demonstration of how dropping files on AppleScript icon works. Shows how to debug via on run path. Shows items added to folder.
Save as an Application Bundle. Don't check anything.
Shows log statement.
It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on. Here is an example.
For testing, run in the Script Editor.
1) Click on the Event Log tab to see the output from the log statement
2) Click on Run
Author: rccharles
*)
-- Gets invoked here when you run in AppleScript editor.
on run
-- debug lines
set desktopPath to (path to desktop) as string
-- here is a log statment.
log "desktopPath = " & desktopPath
-- Be sure to select a file on your DESKTOP.
set see to alias (desktopPath & "picture.jpg")
-- Simulate dropped items list.
set dropped_items to {see}
common(dropped_items)
end run
-- Gets invoked here when something is dropped on the folder
-- Folder actions.
on adding folder items to this_folder after receiving added_items
common(added_items)
end adding folder items to
-- Gets invoked here when something is dropped on this AppleScript icon
on open dropped_items
display dialog "Number of items dropped is " & (count of dropped_items) & ". " giving up after 3
common(dropped_items)
display dialog "Processed " & (count of dropped_items) & " items. " giving up after 2
end open
on common(dropped_items)
-- Write a message into the event log.
log " --- Starting on " & ((current date) as string) & " --- "
log "class = " & class of dropped_items
repeat with droppedItem in dropped_items
-- display dialog "here is something that we got as input: " & droppedItem giving up after 2
set unixDroppedPath to POSIX path of droppedItem
log "unixDroppedPath = " & unixDroppedPath
set quotedUnixDroppedPath to quoted form of unixDroppedPath
log "quoted form is " & quotedUnixDroppedPath
try
set fromUnix to do shell script "sips -r 90 " & quotedUnixDroppedPath
-- display dialog "sips -r 90 of " & quotedUnixDroppedPath & return & " unix says " & fromUnix giving up after 1
on error errMsg
log "sips -r 90 error..." & errMsg
display dialog "error from sips -r 90 of " & errMsg
end try
end repeat
end common
insert a preview rotated image.
insert a sips rotated image.