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?

  • Exactly how much ram is it using?
    – airsquared
    Sep 25, 2018 at 15:03
  • Gigs and gigs...
    – Jason
    Sep 25, 2018 at 15:07
  • One possible solution - experimenting with it now - is to create a "worker" workflow with all of the rotation and have the main workflow pass each sub-folder to the worker so it releases the ram
    – Jason
    Sep 25, 2018 at 15:09
  • This a big mystery. When I use sips, the image displays as expected. When I used preview in the past say three years ago on macos yosemite, I had problems when uploading to the web. Today, both methods appear to be working as expected. Images were rotated on google sites sites.google.com/site/generalsiteforrandompage/rotated-images Feb 1, 2019 at 0:11
  • Can I ask why you need the bits actually changed? Doing that involves creating a new graphics data object, transforming the data, and saving a new file. (Some implementations might not copy metadata, like EXIF, in the process.) JPEG artefacts will increase, if you're using JPEG. The purpose of the rotation 'flag' value in the file format is to perform the rotation with minimal effort and avoid altering the image data.
    – benwiggy
    Feb 1, 2019 at 11:18

3 Answers 3


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}


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


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


    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

            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.

preview rotated image

insert a sips rotated image.

sips rotated image


You can use the Preview.app to perform that task. Create a new service called RotateLeft like this:

enter image description here

and paste this code:

on run
    tell application "System Events"
        key code 36 -- Enter --> Open rename field
        delay 0.1
        key code 0 using command down -- command+A --> select all to include extension
        delay 0.1
        key code 8 using command down -- Copy name to clipboard
        delay 0.1
        key code 36 -- Enter --> Close rename field
        delay 0.1
        set fileName to the clipboard as text -- retrieve file name
        delay 0.1
        key code 31 using command down -- Command+O --> Open file (Default application must be Preview)
        delay 0.1
        repeat until exists window fileName of application process "Preview" -- Make sure image is open
            delay 0.1
        end repeat
        delay 0.1
        key code 37 using command down -- Command+L --> Rotate Left
        delay 1 -- If you are using really big images rise this value so the program can do the task
        key code 13 using command down -- Command+W --> Close image (use code 12 if you want to Quit every time)
        delay 0.1
        set the clipboard to {} -- erase clipboard
    end tell
end run

Before using the Service you must allow Preview under Security/Privacy/Accessibility like this:

enter image description here

You can change the delay values to fit your needs. Also add a shortcut under Preferences/Keyboard/Shortcut/Services. Remember to duplicate the service using key code 15 (Command+R) instead of key code 37 to do RotateRight.

  • fyi: The gui version of preview, just sets flags to have the image rotated on viewing. Jan 30, 2019 at 3:49
  • @historystamp wrong. Jan 30, 2019 at 23:48
  • Try uploading the image to an html page and see what the results are. For me in 10.10.5, I rotated the image in preview. I uploaded the image to the web only to find the image had not been rotated. Jan 31, 2019 at 23:19
  • I did find the image uploaded after a preview rotate to this site ended up rotated. Jan 31, 2019 at 23:36

There is a new "Quick Action" in Mojave that Rotates Images (Left).

Is that any better?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .