-->

Previous | Table of Contents | Next

Page 243

Hour 16

Graphics Tools

In this hour you'll be introduced to a variety of graphics programs and utilities for Linux. This hour starts with a short discussion of different graphics formats you'll find on your system, then shows you how to convert graphics using filter programs and other graphic utilities. These programs are useful for creating, editing, and translating graphics imported from other computer systems.

You'll find a treasure trove of great graphics programs on this book's CD-ROM, and you're likely to be impressed with their usefulness and versatility. You'll be able to translate nearly any type of graphic, and will be able to perform sophisticated operations to transform your graphics files.

Understand Linux Graphics File Formats

There are many different types of graphics file formats, and examples of several types are installed in your system. You may already be familiar with several different formats, especially if you've used other computer operating systems. However, when you use Linux, expect to run into graphics files in formats you've never seen before.

Many files can be recognized by the filename's extension, or letters following

Page 244

a period in the filename. For example, you may recognize .GIF, .PCX, .TIF, or .JPG as common extensions. In Linux, you'll also find files in formats such as .xbm or .xpm installed on your system. The /usr/X11R6/include/X11/bitmaps directory contains nearly 100 different bitmap files, and the /usr/X11R6/lib/X11/xfm directory contains more than 100 black-and-white bitmap icons, as well as more than 110 color pixmap icons.

Table 16.1 is a list of some of the graphics formats, along with relevant conversion programs you'll find on your system. To convert a graphic image from one format to another, see the manual page for the relevant conversion program.

Table 16.1. Linux graphics formats and conversion programs.


Format Type Conversion Program
.10x Gemini 10X pbmto10x
.3d Red/Blue 3D pixmap ppm3d
.asc ASCII text pbmtoascii
.atk Andrew Toolkit raster atktopbm
pbmtoatk
.bg BBN BitGraph graphic pbmtobg
.bmp Windows, OS/2 bitmap bmptoppm
ppmtobmp
.brush Xerox doodle brush brushtopbm
.cmu CMU window manager bitmap cmuwmtopbm
pbmtocmuwm
.ddif DDIF image pnmtoddif
.dxb AutoCAD database file ppmtoacad
sldtoppm
.dvi TeX printer file dvips
dvilj4
dvilj4l
dvilj2p
dvilj
.epsi PostScript preview bitmap pbmtoepsi
.epson Epson printer graphic pbmtoepson
.fits FITS file fitstopnm

Page 245

Format Type Conversion Program
pnmtofits
.g3 Group 3 fax file g3topbm
pbmtog3
.gif Graphics Interchange giftopnm
gif2tiff
ppmtogif
.go Compressed GraphOn pbmtogo
.gould Gould scanner file gouldtoppm
.icn Sun icon icontopbm
pbmtoicon
.ilbm IFF ILBM file ilbmtoppm
ppmtoilbm
.img GEM image file gemtopbm
pbmtogem
imgtoppm
.icr NCSA ICR raster ppmtoicr
.jpeg JPEG cjpeg
djpeg
jpegtran
.lj HP LaserJet data pbmtolj
.ln03 DEC LN03+ Sixel output pbmtoln03
.mgr MGR bitmap mgrtopbm
pbmtomgr
.mitsu Mitsubishi S340-10 file ppmtomitsu
.mtv MTV ray tracer mtvtoppm
.pbm Portable bitmap pbm*
.pcl HP PaintJet PCL ppmtopjxl
.pcx PCX graphic pcxtoppm
ppmtopcx
.pgm Portable graymap pbmtopgm

                                                   continues

Page 246

Table 16.1. continued


Format Type Conversion Program
pgmtoppm
ppmtopgm
.pi1 Atari Degas file pi1toppm
ppmtopi1
.pi3 Atari Degas file pbmtopi3
pi3topbm
.pict Macintosh PICT file picttoppm
ppmtopict
.pj HP PaintJet file pjtoppm
ppmtopj
.pk PK format font pbmtopk
pktopbm
.plot UNIX plot file pbmtoplot
.png Portable Network Graphic pngtopnm
pnmtopng
.pnm Portable anymap pnm*
.pnt MacPaint file macptopbm
pbmtomacp
.ppm Portable pixmap ppm*
.ps PostScript (lines) pbmtolps
pnmtops
.ptx Printronix printer graphic pbmtoptx
.qrt QRT ray tracer qrttoppm
.ras Sun rasterfile pnmtorast
rasttopnm
.sgi Silicon Graphics image pnmtosgi
sgitopnm
.sir Solitaire graphic pnmtosir

Page 247

Format Type Conversion Program
sirtopnm
.sixel DEC sixel format ppmtosixel
.spc Atari Spectrum file spctoppm
.spu Atari Spectrum file sputoppm
.tga TrueVision Targa file ppmtotga tgatoppm
.tiff Tagged File Format pnmtotiff tifftopnm ppmtotiff tiff2ps
.txt text file bitmap pbmtext
.uil Motif UIL icon ppmtouil
.upc Universal Product Code pbmupc
.x10bm X10 bitmap pbmtox10bm
.xbm X11 bitmap pbmtoxbm
xbmtopbm
.xim Xim file ximtoppm
.xpm X11 pixmap ppmtoxpm
xpmtoppm
.xv xv thumbnail xvminitoppm
.xvpic xv thumbnail file xvpictoppm
.xwd X11 Window Dump pnmtoxwd
xwdtopnm
.ybm Bennet Yee face file pbmtoybm
ybmtopbm
.yuv Abekas YUV file ppmtoyuv
yuvtoppm
.zeiss Zeiss confocal file zeisstopnm
.zinc Zinc bitmap pbmtozinc

Converting and Viewing Graphics

Page 248

There are a number of ways to convert graphics files to different formats using the programs you'll find installed on your system. A number of painting or drawing programs discussed in this hour translate graphics. Many programs in Table 16.1 also work as filters in piped commands (see Hour 6, "Using the Shell," for details) to translate graphics.

You can use different combinations of these commands to convert files. The resulting files, which may display and print the same, usually aren't the same file size, so a side benefit of converting graphics may be to save disk space. Look at the following example:


# xwd >graphic.xwd

# xwdtopnm <graphic.xwd | pnmtotiff >graphic2.tiff

xwdtopnm: writing PPM file

pnmtotiff: computing colormap...

pnmtotiff: 6 colors found

# ls -l graphic.xwd graphic2.tiff

-rw-rw-r--   1 bball    bball      240380 Jan  5 15:15 graphic.xwd

-rw-rw-r--   1 bball    bball       15278 Jan  5 16:51 graphic2.tiff

The first command line uses the xwd client to create an X11 window dump graphic (after you select a window and press your left mouse button). Then the window dump file is converted to a portable anymap format, and this stream is fed into the pnmtotiff command to create a .tiff graphic. As you can see, the .tiff graphic file format is nearly 16 times smaller than the X11 window dump graphic.

There are also many graphics programs not listed in Table 16.1 that can be used to alter graphic images. For example, the pnmrotate, pnmsmooth, or pnmscale commands rotate, smooth, and resize graphic images. You can use a variety of these programs to not only convert graphics, but change their appearance or orientation.

If you're using pipes to convert a graphic, you also can change the image on the fly by applying these filter programs. The previous example, now has a filter inserted during the conversion:


# xwd >graphic.xwd

# xwdtopnm <graphic.xwd | pnmflip -topbottom | pnmtotiff >graphic.tiff

xwdtopnm: writing PPM file

pnmtotiff: computing colormap...

pnmtotiff: 6 colors found

Here a window dump is created, and then, using the pnmflip program, it is turned upside down and backwards before creating the .tiff version. Combinations of different filters achieve different effects.

Previous | Table of Contents | Next