[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

20. Importing Images

While you can always make your own images, you may sometimes want to import and use existing images from other sources. In this chapter, I'll show how to import images from scanners and Kodak PhotoCD discs. We'll begin with recipes for taking screen shots.

20.1 Taking Screen Shots  Taking screen shots.
20.2 Scanning Images  Scanning images with a scanner.
20.3 Extracting PhotoCD Images  Taking images off a Kodak PhotoCD.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

20.1 Taking Screen Shots

A screen shot is a picture of all or part of the display screen. The following recipes show you how to take screen shots in X and in the console.

20.1.1 Taking a Screen Shot in X  Taking an X screen shot.
20.1.2 Taking a Screen Shot in a Console  Taking a console screen shot.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

20.1.1 Taking a Screen Shot in X

@sf{Debian}: `imagemagick'
@sf{WWW}: ftp://ftp.wizards.dupont.com/pub/ImageMagick/

Use import, part of the ImageMagick suite, to take a screen shot in X. import can capture the entire screen, a single window, or an arbitrary rectangular area, taking as an argument the name of the file to save to. As with other ImageMagick tools, the image format of the output file depends on the file extension you specify: `.eps' for EPS, `.tiff' for TIFF, `.jpeg' for JPEG, and so on. (For a complete list, see Converting Images between Formats).

After you give the command, the mouse pointer changes to a set of cross-hairs. You then use the mouse to specify which window to take the shot of, as follows:

When you specify a window, import captures only the window's contents; use the `-frame' option to include the window manager frame in the image.

In this example, the capture is saved to a file called `session-1.png'.

NOTE: The system bell rings once when the screen capture starts, and twice when the captures finishes.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

20.1.2 Taking a Screen Shot in a Console

To take screen shots in a virtual console, use cat to save the contents of the device file corresponding to that virtual console; these files are in the `/dev' directory, and are in the format `vcsnumber', where number is the number of the virtual console.

For example, if the target console is the first virtual console (which you would see by typing ALT-F1), the device to cat is `/dev/vcs1'.

NOTE: You must have superuser privileges to access these files (see section Administrative Issues).

Take the screen shot from a virtual console different from the one you want to take a shot of; if you try to take it from the same console you want to capture, the command line you give will be included in the shot! (Kind of like having your thumb in front of the lens while taking a photograph.)

Screenshots taken of virtual consoles, as shown here, are saved as text files; you can't take screen shots of virtual consoles when graphics are displayed.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

20.2 Scanning Images

@sf{Debian}: `sane'
@sf{WWW}: http://www.mostang.com/sane/

SANE, "Scanner Access Now Easy," is the de facto Linux scanner interface; use it to scan an image with a scanner and save it to a file.

SANE works with a wide array of scanning hardware, but make sure the scanning hardware you want to use is compatible by checking the Hardware HOWTO and SANE's list of supported scanners.

Once you have SANE running, you can scan images with SANE-aware applications like the GIMP (see section Editing Images with the GIMP).

The following recipes describe use of the command-line scanimage tool, which comes with the SANE package.

NOTE: As the acronym implies, getting a scanner to work on a Linux system hasn't always been smooth going. The SANE interface is completely open, and its developers are making sure that it is generalized enough to be implementable on any hardware or operating system.

20.2.1 Listing Available Scanner Devices  Listing available scanners.
20.2.2 Testing a Scanner  Testing a scanner.
20.2.3 Scanning an Image  Scanning an image.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

20.2.1 Listing Available Scanner Devices

Before you can use a scanner device, you need to know its device name. To get this name, use scanimage with the `--list-devices' option.

 
$ scanimage --list-devices RET
device `umax:/dev/sgb' is a UMAX     Astra 1220S      flatbed scanner
$

In this example, there's one scanning device on this system, a UMAX brand scanner that can be specified to scanimage by giving its device name, `umax:/dev/sgb', as an argument to the `-d' option.

To list the available resolutions and options supported by a particular device, use the `--help' option along with the `-d' option followed by its device name.

NOTE: For all scanimage commands, specify the scanner device you want to use by including the `-d' option with the device name.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

20.2.2 Testing a Scanner

To run diagnostic tests on a scanner to make sure that it can be properly read from, use scanimage with the `--test' option.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

20.2.3 Scanning an Image

@sf{Debian}: `netpbm'
@sf{WWW}: http://www.debian.org/Packages/stable/graphics/netpbm.html

Use scanimage to scan an image. Most scanners let you specify the x and y values, in pixels, for the image size to scan, starting from the top-left corner of the scanner bed. Give these coordinates as arguments to the `-x' and `-y' options. Also, give an argument to the `--resolution' option to specify the scan resolution, given in dpi ("dots per inch"). Common resolution values include 72, 120, 300, and 600 dpi; 72 dpi is the most popular resolution for use on the Web or for viewing on screen, and 204 dpi is often used for images that you want to send on a fax machine.

Scanned output is sent to standard output, so to scan an image to a file, redirect the standard output.

scanimage outputs images in the PNM ("portable anymap") formats, so make sure that you have the `netpbm' package (installed on most Linux systems by default); it's a useful collection of tools for converting and manipulating these formats. The formats output by scanimage are as follows:

FORMAT DESCRIPTION
PPM Color images.
PBM Black and white images.
PGM Grayscale images.

Use the `--mode' option to specify the format of the output, followed by one of the following arguments: `color' for color PPM, `gray' for PGM grayscale, or `lineart' for black and white PBM. Each scanner has a default mode; for most color scanners, the default mode will be `color'.

NOTE: The command lines in this recipe are split across two lines because they're too long to fit on one, but type these commands on one long line.

Once the image has been scanned and written to a file, you can edit it just as you would any image.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

20.3 Extracting PhotoCD Images

@sf{Debian}: `xpcd'
@sf{WWW}: http://user.cs.tu-berlin.de/~kraxel/linux/xpcd/

There are two methods to extract an image from Kodak PhotoCD(30) ("PCD"). If you are browsing the disc with the xpcd tool, then choose an image, extract a copy at the desired resolution, and save it to a file, as described in Browsing PhotoCD Archives.

You can also use pcdtoppm on a PCD file directly to extract an image at a given resolution and save it to a file in PPM format. Use the `-r' option to specify the resolution to extract, given as a numeric argument from 1 (lowest resolution) to 5 (highest); if this option is omitted, a value of 3 is assumed. Also give as arguments the name of the PCD file to read from and the name of the PPM file to write to.

20.3.1 Converting a PhotoCD Image  Converting PhotoCD images to other formats.
20.3.2 Removing PhotoCD Haze  Removing the "haze" from a PhotoCD image.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

20.3.1 Converting a PhotoCD Image

Once you extract a PhotoCD image and write it to a PPM format file, use convert to convert it to another format and adjust or improve the image (see section Converting Images between Formats).

To improve the image while you convert it to JPEG format, specify no interlacing with the `-interlace' option, 50 percent image sharpening with the `-sharpen' option, and add an optional border and annotation to the image with the `-border' and `-comment' options.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

20.3.2 Removing PhotoCD Haze

@sf{Debian}: `gimp'
@sf{WWW}: http://www.gimp.org/

Extracted PhotoCD images are known to sometimes have a kind of "green haze" over them; to remove it, open the image in the GIMP and adjust the color levels with the Auto Levels function. This technique, adapted from a tip for using PhotoCD by Philip Greenspun, works well for improving any scanned or imported image.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated using texi2html