Posted On 2007-05-01 by FortyPoundHead
Keywords: Command Reference
Tags: Linux Commandline Linux
Views: 1541

Capture some or all of an X server screen and save the image to file.

import [ options ... ] [ file ]
import reads an image from any visible window on an X server and outputs it as an image file.
You can capture a single window, the entire screen, or any rectangular portion of the screen.

The target window can be specified by id, name, or may be selected by clicking the mouse in the desired window.

If you press a button and then drag, a rectangle will form which expands and contracts as the mouse moves. To save the portion of the screen defined by the rectangle, just release the button. The keyboard bell is rung once at the beginning of the screen capture and twice when it completes.


To select an X window with the mouse and save it in the MIFF image format to a file titled MyTest.miff, use:

import MyTest.miff

To save the desktop to a jpeg file, use:

import -window root MyTest.jpg

Although not strictly speaking part of the shell `import'' seems to be present on most linux distributions.

-border include image borders in the output image.

-colors valuepreferred number of colours in the image. The actual number of colours in the image may be less than your request, but never more.

-colorspace valueThe type of colorspace: GRAY, OHTA, RGB, Transpar*ent, XYZ, YCbCr, YIQ, YPbPr, YUV, or CMYK.
colour reduction, by default, takes place in the RGB colour space.

The Transparent colour space behaves uniquely in that it preserves the matte channel of the image if it exists.
The -colors or -monochrome option is required for this option to take effect.

-comment stringannotate an image with a comment.

-compress typeThe type of image compression: None, BZip, Fax, Group4, JPEG, LZW, RunlengthEncoded, or Zip.
Specify +compress to store the binary image in an uncompressed format. The default is the compression type of the specified image file.

-delay <1/100ths of a second>x display the next image after pausing.
This option is useful for regulating the display of the sequence of images. 1/100ths of a second must expire before the display of the next image. The default is 6/100 of a second between each frame of the image sequence. The second value is optional. It specifies the number of seconds to pause before repeating your animation sequence.

-density x
vertical and horizontal resolution in pixels of the image.

include window manager frame.

-geometry x{+-}{+-}{%}{!}{<}{>}
the width and height of the image.

-interlace typeThe type of interlacing scheme: None, Line, Plane, or Partition. The default is None.
This option is used to specify the type of interlacing scheme for raw image formats such as RGB or YUV.

No - means do not interlace (RGBRGBRGBRGBRGBRGB...)
Line - uses scanline interlacing (RRR...GGG...BBB...RRR...GGG...BBB...)
Plane - uses plane interlacing (RRRRRR...GGGGGG...BBBBBB...)
Partition - is like plane except the different planes are saved to individual files (e.g. image.R, image.G, and image.B)

Use Line, or Plane to create an interlaced GIF or progressive JPEG image.

-label name assign a label to an image.Use this option to assign a specific label to the image.

transform image to black and white.

replace every pixel with its complementary colour (white becomes black, yellow becomes blue, etc.)
Use +negate to only negate the grayscale pixels of the image.

-quality valueJPEG/MIFF/PNG compression level.
For the JPEG image format, quality is 0 (worst) to 100 (best). The default quality is 75.
Quality for the MIFF and PNG image format sets the amount of image compression (quality / 10) and filter-type (quality % 10). Compression quality values range from 0 (worst) to 100 (best).

-rotate degrees{<}{>}apply Paeth image rotation to the image.

Use > to rotate the image only if its width exceeds the height. < rotates the image only if its width is less than the height. For example, if you specify -90> and the image size is 480x640, the image is not rotated by the specified angle. However, if the image is 640x480, it is rotated by-90 degrees. Empty triangles left over from rotating the image are filled with the colour defined as bordercolor (class borderColor).

-scene value Number of screen snapshots.
Use this option to grab more than one image from the X server screen to create an animation sequence.

-screen This option indicates that the GetImage request used to obtain the image should be done on the root window, rather than directly on the specified window. In this way, you can obtain pieces of other windows that overlap the specified window, and more importantly, you can capture menus or other popups that are independent windows but appear over the specified window.

operate silently, i.e. don''t ring any bells.

-transparency color
make this colour transparent within the image.

-treedepth value Normally, this integer value is zero or one. A zero or one tells convert to choose a optimal tree depth for the colour reduction algorithm.
Try values between 2 and 8 for this parameter.

-verbose print detailed information about the image. This information is printed: image scene number; image name; image size; the image class (Direct- Class or PseudoClass); the total number of unique colours; and the number of seconds to read and write the image.

-window id select window with this id or name. With this option you can specify the target window by id or name rather than using the mouse. Specify `root'' to select X''s root window as the target window.

All Options are processed in command line order. Any option you specify on the command line remains in effect until it is explicitly changed by specifying the option again with a different effect.

file specifies the image filename. If file is omitted, it defaults to magick.miff. The default image format is MIFF. To specify a particular image format, precede the filename with an image format name and a colon (i.e. gif:image) or specify the image type as the filename suffix (i.e. image.jpg). See convert(1) for a list of valid image formats.

Specify file as - for standard output. If file has the extension .Z or .gz, the file size is compressed using with compress or gzip respectively. Precede the image file name | to pipe to a system command. If file already exists, you will be prompted as to whether it should be overwritten.

About the Author

FortyPoundHead has posted a total of 1974 articles.


Comments On This Post

No comments on this post yet!

Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.

Your IP address is:

Before you can post, you need to prove you are human. If you log in, this test goes away.

Recent Forum Posts

List of Shady Characters
dwirch posted on April 25, 2017 at about 16:39 in Webmaster Stuff

Job Spammer: Bilal Uddin
dwirch posted on April 25, 2017 at about 11:00 in Spammers

Bug Fix: Contact Form Error
dwirch posted on April 21, 2017 at about 11:38 in Site News

Bug Fix: Ophion Time Tracker
dwirch posted on April 9, 2017 at about 11:30 in Site News

Job Spammer: Yogesh Kapadne
dwirch posted on March 31, 2017 at about 8:04 in Spammers

Job Spammer: Sathya Narayana
dwirch posted on March 15, 2017 at about 7:18 in Spammers