Screenshots with ImageMagick

This article is kept for historical reasons, but is no longer updated: see https://docs.trueelena.org/desktop/desktop_environment/index.html for up-to-date instructions.

The graphical suite ImageMagick includes a tool, import, that is able to save a visible window in an X server.

Plain Screenshots

Section

The default behaviour of import is to take a custom rectangular portion of the screen; just launch:

import $FILENAME

and drag the cursor to select the area you are interested into.

Fullscreen

You can select the window you want to save with the -window option; to get a picture of the whole screen you can use the root window:

import -window root $FILENAME

One window

To save any specific window you need to know its name or id; you can get them with the xwininfo command, e.g. with:

import -window `xwininfo | awk '/.*Window id:.*/ {print $4}'` $FILENAME

click on the window you are interested and let import do its work.

If you want to include window borders in the image you can add the -border option:

import -border -window `xwininfo | awk '/.*Window id:.*/ {print $4}'` \
$FILENAME

Not So Plain Screenshots

Running Screensaver

For this, you'll need remote access to the computer, e.g. via ssh, or some other mean to launch a command without touching the keyboard (cron?); once you're logged with the same user that is running the X session, you can take a shot of the screensaver with:

DISPLAY=:0 import -window root $FILENAME

I'm not sure whether this would work with 3D screensavers, but it does with simple 2D ones.

Send a comment: unless requested otherwise I may add it, or some extract, to this page.

Return to Top