Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Use Automator to create standardized screen grabs Apps
One of my sites required that I supply it images that were all the exact same size: 100 pixels by 100 pixels. After twiddling around with various Photoshop actions, robg suggested that I use Automator. This was a great suggestion in theory, but quickly posed some problems when trying to accomplish my task with only the actions Apple supplied.

The solution:

Using the following tools and some help from robg, I managed to put together a nice little workflow that would allow me to grab a partial screen shot at any size and ratio, save the image to a folder, resize the image to 100 pixels on the largest side of the image, and finally, pad the shorter size of the image up to 100 pixels with white space. Using these tools, you can easily pad the image to any size, and select the background colour you want.

Tools required:
  • Snapz Pro X
  • Automator
  • Ben Long's free Photoshop Automator Actions. Since Preview's Pad Images Automator action only pads in black, it was not going to be useful for my purpose. Enter Photoshop Automator Actions. These actions are available for the CS, CS2, and CS3 versions of Photoshop.
Read on for the step-by-step solution...

The process starts with Ambrosia's SnapzPro. This little application is a must-have for any Mac user's arsenal. First, create a folder inside your Pictures folder called ScreenGrabs. Next, set up the preferences in SnapzPro with 'Open after saving' unchecked, 'Choose file name' checked, and 'Stick around' unchecked. Since any folder inside the Pictures folder will show up in the drop down for 'Send to:' in SnapzPro, I can set the 'Send to:' location to the folder I just created (ScreenGrabs).

Next, we need to create our Automator workflow and attach it as a folder action to the ScreenGrabs folder we created above. If you don't already have the Photoshop Automator Actions installed, now is the time to download and install them. Launch Automator, choose File » New, and for our purposes, we will be creating a five-step workflow. Note that for the purpose of this little how-to, I am using Photoshop CS, if you have CS2 or CS3, then be sure to choose the CS2 or CS3 actions.

Here are the five steps in the Automator workflow, in the form of Library » Action:
  1. Photoshop CS » Open
    We don't need to do anything else with this action as we are saving this workflow as a folder action. No Open location is required.
  2. Photoshop CS » Scale Image
    Here is where we set up the preferences to get the correct image size. For my purposes, I chose 'Scale image proportionally, so that its [Longest] side is:' and then entered a length of 100 [Pixels]. Resolution I set to 72 ppi (points per inch).
  3. Photoshop CS » Resize Canvas
    This is the step to pad the image. You can do all sorts of things here to your image, including creating a nice coloured border around it. For my purpose, I chose a Width of 100 and Height of 100, and Anchor: [Middle Center]. Units are pixels, and Background color [White].
  4. Photoshop CS » Render
    A little note about this step: When I first built my workflow, I could not for the life of me figure out why the Photoshop CS actions appeared to do nothing. Then robg suggested that I should tell Photoshop to Render my changes from steps one through three. Thanks, robg, you saved my sanity (reading the manual would have helped, too). So, as you can guess by now, the Render action renders all the previous actions for Photoshop CS. For our purposes, we will simply choose Save (Saves over the original file).
  5. Automator » Run Applescript
    This last step is optional. Since I was uploading all my images onto my website through the browser, I needed a way to quickly find the local path of the image that we just created. The following little AppleScript will do just that by placing the full local path of the new image into the clipboard. The original AppleScript was not my own, but I unfortunately forgot where I found it. So to the original author, my apologies and my thanks. I did, however, modify the original script a fair amount, so in essence it is an original work. Here's the code:
    on run {input, parameters}
      tell application "Finder"
        set p to POSIX path of input
        set the clipboard to p as text
      end tell
      return input
    end run
That's it. Now save the workflow with File » Save As Plug-in, and choose Folder Actions for the 'Plug-in for' option. Then choose the ScreenGrabs folder you created above, give your workflow a name, and you're done.

To test your new action do the following: Find an image you want to turn into an icon, then hit Shift-Command-3 (the default keys to activate SnapzPro). Choose 'Selection...' from the SnapzPro pop-up window (third button from the left), then be sure that the next SnapzPro screen looks similiar to this:

Basically, that's just the default settings for Snapz. Next, drag the selection for SnapzPro over the image you want to grab and hit Enter. Then type in a name for your image and hit Enter again.

SnapzPro will save the image into the ScreenGrabs folder, and the folder action will trigger the Automator action. After a few seconds, the Desktop will come to the front, which basically means your image is ready. Now go to the ScreenGrabs folder and check out that perfect 100x100 icon you just made.
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)

10.4: Use Automator to create standardized screen grabs | 2 comments | Create New Account
Click here to return to the '10.4: Use Automator to create standardized screen grabs' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Use Automator to create standardized screen grabs
Authored by: Doc Drang on Sep 27, '07 10:34:21AM
Photoshop seems like overkill for this--and many of us don't have it. Apple supplies a command-line tool, sips, that can resize and pad images. Enter "sips --help" in a Terminal window to see what you can do. You can combine it with the screencapture command to grab and resize sections of the screen. I wrote a little utility for doing this a while ago; you can see it and my description here.

Doc Drang

[ Reply to This | # ]

10.4: Use Automator to create standardized screen grabs
Authored by: Peganthyrus on Sep 28, '07 05:26:51PM

IMHO this sounds like a task that might belong in the back-end of your website, instead of in your posting workflow. It depends on how your site is maintained, of course - if you don't have a CMS of any kind and edit everything with iWeb or Textmate or whatever, then local automation like this is great!

[ Reply to This | # ]