hoopajoo.net
Screenshot
Screenshot
⇐ Back to X

Questions, comments, or corrections? Send me a message.

There are several ways to get a screenshot in X. You can use gimp do a screen capture, xv and do the same, xwd, or a plethora of other tools. Personally, for ease, I prever xwd, and actually it's what gimp uses to grab screenshots.

The xwd command is pretty simple in itself, it just dumps a window to a file. A window you say? But I want a screenshot! Well, there's hope. To get the whole screen, use the -root option. You can also use the -out option to specify an output file or pipe the output to a file. So fire up an xterm and try:

xwd -root -out screen.xwd

OK, you have a .xwd file, so now what? Now do whatever you want with it. :) Most likely you'll want to convert it to a jpg or gif to put on the web or send to someone, so you could open it in gimp and "Save As..." to convert it. Unfortunately I've had lots of problems with xv and .xwd files, so I wouldn't recommend using xv for it. I'm lazy though, and having to fire up a whole graphic editor to make a simple change seems like overkill to me. Now comes convert to the rescue, that is if you have ImageMagick installed, and many distributions do. If not, visit their website and get the package to install. It's worth it since it allows you to quickly and easily do simple manipulations on graphics.

The convert command, at it's most rudimentary level, is pretty simple. Just do:
convert INPUT.file OUTPUT.file

And from the input and output file names, it can usually figure out what to do. For example, to convert our .xwd file to a .jpg:
convert screen.xwd screen.jpg

And there you have it. It will have converted the .xwd to a .jpg automagically. The other option I use a lot, doing webwork and stuff, is the -sample option. This will let you create a quick preview image from another image. For example, on my desktop page I have a preview image. While you could again fire up gimp for this, convert is much easier. I have a 500x400 preview image so I do this:
convert screen.jpg -sample 500x400 screen_little.jpg

That's it, now there's a screen_little.jpg that's been scaled to 500x400 pixels. Now to put it all together. Usually you'll want to have a second or two to navigate to the desktop you want a screen shot of, so try this one-liner to create and convert the file after waiting 5 seconds:
sleep 5s ; xwd -root -out screen.xwd ; convert screen.xwd screen.jpg

After running this you'll get a screen.jpg file of the screen you were on about 5 seconds after you launched the command line. Of course ImageMagick has lots of other cool stuff, so check out the convert man page and the docs that come with it.