|[<--] [Cover] [Table of Contents] [Concept Index] [Program Index] [-->]|
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.
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.
Debian: `imagemagick' WWW: ftp://ftp.wizards.dupont.com/pub/ImageMagick/
import, part of the ImageMagick suite, to take a screen shot
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.
$ import -frame session-1.png [RET]
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.
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
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'.
$ cat /dev/vcs4 > screenshot [RET]
NOTE: You must have superuser privileges to access these files (see 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.
Debian: `sane' 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 Editing Images with the GIMP).
The following recipes describe use of the command-line
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.
Before you can use a scanner device, you need to know its device
name. To get this name, use
scanimage with the
$ 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'
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.
$ scanimage --help -d 'umax:/dev/sgb' [RET]
NOTE: For all
scanimage commands, specify the scanner
device you want to use by including the `-d' option with the device
To run diagnostic tests on a scanner to make sure that it can be
properly read from, use
scanimage with the `--test' option.
$ scanimage --test -d 'umax:/dev/sgb' [RET]
Debian: `netpbm' WWW: http://www.debian.org/Packages/stable/graphics/netpbm.html
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:
||Black and white images.|
$ scanimage -d umax:/dev/sgb --resolution 72 -x 200 -y 100 > scan.ppm [RET]
$ scanimage -d umax:/dev/sgb --resolution 300 --mode lineart -x 180 -y 225 > scan.pbm [RET]
Debian: `xpcd' 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
$ pcdtoppm -r5 slack.pcd slack.ppm [RET]
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 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.
$ convert -interlace NONE -sharpen 50 -border 2x2 -comment 'Bob was here' slack.pnm slack.jpeg [RET]
Debian: `gimp' 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.
Imagemenu to the
Colorssubmenu and then to the
Levelssubmenu, and choose
Levelswindow to accept the changes.
[<--] [Cover] [Table of Contents] [Concept Index] [Program Index] [-->]