Taking Screenshots In Mac OS X

Often you know what you are looking for but do not have its name, thus are stymied for finding it. Taking screenshots in Mac OS X could be like that for anyone not raised on an earlier Mac OS. Here is the skinny.

Before you tell me that Mac OS X comes with a utility called Grab, allow me to interject Grab's primary limitation. While it captures an entire screen or any selected portion of it handily, it presently does not capture a single window. Try it; you'll find that feature greyed out. There is no sign that Apple is spending any resources to fill out Grab's feature set anytime soon either. Here is a case for open source software. Had the source code for Grab been made available, some clever programmer somewhere would surely have added that feature to it by now. But it hasn't, so it wasn't. There is, however, an alternative.

Mac OS supported a number of keyboard shortcuts, one of which is Cmd-Shift-4 plus Spacebar plus Click over your window of choice. (Can you believe this?) Doing so will get you a screenshot of the window saved to your desktop in Portable Document Format with a name like Picture 1, which you can readily open in Preview.

If it were all that simple, there wouldn't be enough material for an article. But it isn't, so there is. If you are cooking web pages that include embedded graphics, you probably don't want to use pdf files. Instead, you would want a graphic file format that is universally accepted in a web page. Ones that immediately come to mind include gif, jpeg, and png. Well, out of the box OS X doesn't have any tools for creating these types of files, though I am ever-grateful that OS X crunches pdf files so handily. What you need is a free graphics application such as The GIMP.

We discussed The GIMP together a long time ago. In a nutshell, The GIMP is an X Window System application, which is often referred to as X11 protocol. So we need to install not only the application but also an X11 server (which serves up your graphical X11 windows), plus make a couple of tiny tweaks. Since Apple recently brought out an application aptly named X11, we'll use that.

We start by gathering the pieces. If you have less than a basic ADSL connection, this will take a while, possibly forever. Start in the late evening, press Download, and go to bed. It'll be an all-nighter for your modem.

ESP Ghostscript
Apple X11

Download and install each. Installation should be straightforward. Also make the following little tweaks to some configuration files.

sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/ssh_config
sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/sshd_config
sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/csh.login

In the first two, find the lines ForwardX11 and X11Forwarding respectively, and uncomment (remove leading "#") and set them from No to Yes. Save and exit each one with Cmd-Q (that's important). In the third file, use copy and paste to append a path for X11 and add a little code for display purposes, like so:

# System-wide .login file for csh(1).

setenv PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:

# added for sake of X11 displays in Terminal by DMG
if (! $?DISPLAY) then
   setenv DISPLAY :0.0


Doing this will enable X applications to work from a Terminal prompt. For aesthetic's sake, indent the setenv line by about three spaces. Good. Now you can run X11 applications from Terminal.

You also need to inform X11 of your PATH, not your life's destiny, just the path to where you keep stuff on your hard drive. I found a reference to how this is done, and, with all credit and thanks to the authors, I'll pass it on to you now, slightly modified.

The simplest way to handle this is to work from a Terminal prompt. First, determine your current PATH and copy it to the clipboard.




Then open a hidden file in TextEdit like so:

/Applications/TextEdit.app/Contents/MacOS/TextEdit ~/.MacOSX/environment.plist

It will already have some entries. Copy and paste two more, called a key/entry pair, substituting your own path statement for mine in the example, and indenting each line with a tab:


Your end product should look something like this:

Save, exit, logout and login again at your convenience for the setting to take. By the way, the reference above also shows how you can add another pair for DISPLAY and accomplish the same as what I do in the little IF routine above. Much simpler too, once you find out how.

Start X11 and make a menu shortcut for The GIMP, using X11's Applications, Customize... menu like so:

Save and close the window. Now start The GIMP from X11's Application menu. You should have liftoff. From there the idea will be to open the Picture 1 pdf file in The GIMP and save it as a jpg. If you have a three-button mouse, "everything" in The GIMP works with a right-click. Use Cmd-Click with a regular Apple mouse. I like to open the file with higher than default resolution, save it as a jpg, then scale the image back to a manageable size and save again. Doing this preserves resolution nicely.

So play with this for a while, check out The GIMP site, and we can meet again to go over some details and compare notes. No doubt there are other file conversion programs. But I love X and The GIMP, and saw an opportunity here for a plug. I hope you enjoy it as much as I do.

But if you don't and you also have no need for a full-featured graphics editing package, then here is an alternative that you already have installed. Thanks to a tip from HD, you can open your pdf file in Preview, pull down File, Export... from the program menu, select jpg, and Bob's your uncle! This works for any file, not just screenshots. If you need to embed a smaller photo of a scanned document into your web page, then Preview will do the job handily. You can even scale the original by using Preview's print-to-file feature with scaling set to 25%, say, in Page Setup, then export the scaled file to jpg. Voila! The power of Preview is easy to underestimate. I challenge you to go out and price a comparable file conversion utility. You'll quickly discover the dollar value of this feature alone makes Preview worthy of a closer look. Thank you, Steve. And HD, for reminding me. We're all in this together.

By now you'll have heard about Apple's new G5 Power Mac machines. If you thought Apple raised the bar last time around, wait until you see this. Fasten your seatbelts! Happy Independence Day. Ciao.