Tuesday 24 September 2013

Mac Image Batch Processing with terminal

Have you got a pile of images you want to rotate or resize? You can do this really quickly on your Mac using built-in command line aka The Terminal in seconds.

Your out-of-the-box Apple Mac comes with loads of powerful tools that you can only access through The Terminal. As deathly final as that sounds, Terminal is a text-based interface to control your computer, manipulate files and run programmes. Instead of clicking or dragging an icon, you type in a Linux command (here's a list of generally useful Linux commands).

In this case a couple of dozen image files needed to be resized and rotated. The sips (scriptable image processing system) command can be used to resize and rotate many many images in seconds as follows:
1) Put all images to be processed in one folder
2) Open Terminal (type it into Spotlight)
3) Change to the images' folder
4) Converts all files to a maximum width/height of 640 pixels
sips -Z 640 *
5)Rotate all files by 90 degrees clockwise
sips -r 90 *

This command line interface is especially useful when you've got more than a handful of files to process in the same way. Sips can do a lot more to your images - check out the full list
$>sips --help

This tool is used to query or modify raster image files and ColorSync ICC profiles.

Its functionality can also be used through the "Image Events" AppleScript suite.

  Usages:
    sips [-h, --help]
    sips [-H, --helpProperties]
    sips [image-query-functions] imagefile ...
    sips [profile-query-functions] profile ...
    sips [image modification functions] imagefile ...
         [--out result-file-or-dir]
    sips [profile modification functions] profile ...
         [--out result-file-or-dir]

  Profile query functions:
    -g, --getProperty key
    -X, --extractTag tag tagFile
    -v, --verify

  Image query functions:
    -g, --getProperty key
    -x, --extractProfile profile

  Profile modification functions:
    -s, --setProperty key value
    -d, --deleteProperty key
        --deleteTag tag
        --copyTag srcTag dstTag
        --loadTag tag tagFile
        --repair



  Image modification functions:
    -s, --setProperty key value
    -d, --deleteProperty key
    -e, --embedProfile profile
    -E, --embedProfileIfNone profile
    -m, --matchTo profile
    -M, --matchToWithIntent profile intent
        --deleteColorManagementProperties
    -r, --rotate degreesCW
    -f, --flip horizontal|vertical
    -c, --cropToHeightWidth pixelsH pixelsW
    -p, --padToHeightWidth pixelsH pixelsW
        --padColor hexcolor
    -z, --resampleHeightWidth pixelsH pixelsW
        --resampleWidth pixelsW
        --resampleHeight pixelsH
    -Z, --resampleHeightWidthMax pixelsWH
    -i, --addIcon

No comments:

Post a Comment