📄 ch43_25.htm
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 43] 43.25 The Portable Bitmap Package </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly & Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly & Associates, Inc."><METANAME="DC.date"CONTENT="1998-10-23T15:52:11Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="ch43_01.htm"TITLE="43. Printing"><LINKREL="prev"HREF="ch43_24.htm"TITLE="43.24 Other PostScript Utilities "><LINKREL="next"HREF="part08.htm"TITLE="VIII. Shell Programming "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch43_24.htm"TITLE="43.24 Other PostScript Utilities "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 43.24 Other PostScript Utilities "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 43<BR>Printing</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="PART"HREF="part08.htm"TITLE="VIII. Shell Programming "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: VIII. Shell Programming "BORDER="0"></A></TD></TR></TABLE> <HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-9023">43.25 The Portable Bitmap Package </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="UPT-ART-9023-IX-GRAPHICS-CONVERSION-PROGRAMS"></A><ACLASS="indexterm"NAME="AUTOID-49249"></A><ACLASS="indexterm"NAME="AUTOID-49252"></A><ACLASS="indexterm"NAME="AUTOID-49255"></A><ACLASS="indexterm"NAME="AUTOID-49258"></A><ACLASS="indexterm"NAME="AUTOID-49261"></A><ACLASS="indexterm"NAME="AUTOID-49265"></A><ACLASS="indexterm"NAME="AUTOID-49268"></A><ACLASS="indexterm"NAME="AUTOID-49271"></A><ACLASS="indexterm"NAME="AUTOID-49273"></A>There are dozens of formats used for graphics files acrossthe computer industry. There are <EMCLASS="emphasis">tiff</EM> files, <EMCLASS="emphasis">PICT</EM>files, and <EMCLASS="emphasis">gif</EM> files. There are different formats fordisplaying on different hardware, different formats forprinting on different printers, and then there are the internalformats used by graphics programs. This means thatimporting a graphics filefrom one platform to another (or from one program to another)can be a large undertaking, requiring a filter written specially to convertfrom one format to the next. </P><TABLECLASS="para.programreference"BORDER="1"><TR><THVALIGN="TOP"><ACLASS="programreference"HREF="examples/index.htm"TITLE="netpbm">netpbm</A><BR></TH><TDVALIGN="TOP"> The <EMCLASS="emphasis">netpbm</EM> package can be used to convert between a wide varietyof graphics formats. <EMCLASS="emphasis">netpbm</EM> evolved from the original Portable Bitmap Package,<EMCLASS="emphasis">pbmplus</EM>, which was written by Jef Poskanzer.A group of <EMCLASS="emphasis">pbmplus</EM> users on the Internet cooperated to upgrade<EMCLASS="emphasis">pbmplus</EM>; the result was <EMCLASS="emphasis">netpbm</EM>.</TD></TR></TABLE><PCLASS="para">The idea behind <EMCLASS="emphasis">pbm</EM> isto use a set of very basic graphics formats that (almost)all formats can be converted into and then converted back from.This is much simpler than having converters to and from eachindividual format.These formats are known as <EMCLASS="emphasis">pbm</EM>, <EMCLASS="emphasis">pgm</EM>, and <EMCLASS="emphasis">ppm</EM>: the portable bitmap, graymap, and pixmap formats. (A bitmap is atwo-dimensional representation of an image; a graymap has additionalinformation encoded that gives grayscale information for each bit; apixmap encodes color information for each bit.) The name "<EMCLASS="emphasis">pnm</EM>" isa generic name for all three portable interchange formats (with the<EMCLASS="emphasis">n</EM> standing for "a<EMCLASS="emphasis">n</EM>y"), and programsthat work with all three are said to be "anymap" programs. </P><PCLASS="para">The <EMCLASS="emphasis">netpbm</EM> package contains well over a hundred conversionprograms.There are three basic kind of programs:</P><ULCLASS="itemizedlist"><LICLASS="listitem"><PCLASS="para">Programs that convert a graphics file to one of the <EMCLASS="emphasis">pnm</EM>formats. For example, if I had a <EMCLASS="emphasis">tiff</EM> file and I wantedto convert it to PostScript, I might start theprocess by using <EMCLASS="emphasis">tifftopnm</EM>:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>tifftopnm Hobbes.tiff > Hobbes.pnm</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para"></P></LI><LICLASS="listitem"><PCLASS="para">Programs that convert from one of the <EMCLASS="emphasis">pnm</EM> formats toanother format.For example, if I wanted to convert the <EMCLASS="emphasis">Hobbes.pnm</EM> filedirectly to PostScript, I could use <EMCLASS="emphasis">pnmtops</EM>:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>pnmtops Hobbes.pnm > Hobbes.ps</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para"></P></LI><LICLASS="listitem"><PCLASS="para">Programs used to manipulate the image in <EMCLASS="emphasis">pnm</EM> format.For example, if I wanted to crop the image, I could use<EMCLASS="emphasis">pnmcut</EM> before I converted the file to PostScriptand printed it:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>tifftopnm Hobbes.tiff > Hobbes.pnm</B></CODE>% <CODECLASS="userinput"><B>pnmcut 10 10 200 200 Hobbes.pnm > Hobbes.cut</B></CODE>% <CODECLASS="userinput"><B>pnmtops Hobbes.cut > Hobbes.ps</B></CODE>% <CODECLASS="userinput"><B>lpr Hobbes.ps</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">or, on one command line (and without cluttering your disk withintermediary files):</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>tifftopnm Hobbes.tiff | pnmcut 10 10 200 200 | pnmtops | lpr</B></CODE></PRE></BLOCKQUOTE></P></LI></UL><PCLASS="para">I frequently like to create<SPANCLASS="link">X11 (<ACLASS="linkend"HREF="ch01_31.htm"TITLE="The X Window System ">1.31</A>)</SPAN>bitmaps out of pictures in newspapers or magazines. The way I do this is to first scanthe picture in on a Macintosh and save it as <EMCLASS="emphasis">tiff</EM> or <EMCLASS="emphasis">PICT</EM> format.Then I<SPANCLASS="link"><EMCLASS="emphasis">ftp</EM> (<ACLASS="linkend"HREF="ch01_33.htm"TITLE="UNIX Networking and Communications ">1.33</A>)</SPAN>the file to our UNIXsystem and convert it to <EMCLASS="emphasis">pnm</EM> format, and then use <EMCLASS="emphasis">pbmtoxbm</EM>to convert it to X bitmap format. If the picture is too big,I use <EMCLASS="emphasis">pnmscale</EM> on the intermediary <EMCLASS="emphasis">pnm</EM> file. Ifthe picture isn't right-side-up, I can use <EMCLASS="emphasis">pnmrotate</EM>and sometimes <EMCLASS="emphasis">pnmflip</EM> before converting the <EMCLASS="emphasis">pnm</EM>file to X11 bitmap format.</P><PCLASS="para">The programs provided with the <EMCLASS="emphasis">netpbm</EM> package are far too manyto discuss in detail, and some of these formats are onesthat you've probably never even heard of.But here's a summary of them.<ACLASS="xref"HREF="ch43_25.htm#UPT-ART-9023-TAB-0"TITLE="Image Format Conversion Programs">Table 43.2</A>lists the conversion programs.<ACLASS="xref"HREF="ch43_25.htm#UPT-ART-9023-TAB-1"TITLE="Manipulating pnm Files">Table 43.3</A>lists the programs that perform various kinds of editing,enhancement, or transformations on image files. </P><TABLECLASS="table"><CAPTIONCLASS="table"><ACLASS="title"NAME="UPT-ART-9023-TAB-0">Table 43.2: Image Format Conversion Programs</A></CAPTION><THEADCLASS="thead"><TRCLASS="row"VALIGN="TOP"><THCLASS="entry"ALIGN="LEFT"ROWSPAN="1"COLSPAN="1">Format</TH><THCLASS="entry"ALIGN="LEFT"ROWSPAN="1"COLSPAN="1">To pnm</TH><THCLASS="entry"ALIGN="LEFT"ROWSPAN="1"COLSPAN="1">From pnm</TH></TR></THEAD><TBODYCLASS="tbody"><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">ASCII graphics</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">asciitopgm</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">pbmtoascii</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">AT&T 4425 terminal (132 col mode)</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1"></TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">pbmto4425</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">Abekas YUV bytes</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">yuvtoppm</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">ppmtoyuv</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">Abekas YUV triplets (MPEG/JPEG)</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">yuvsplittoppm</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">ppmtoyuvsplit</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">Andrew Toolkit raster object</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">atktopbm</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">pbmtoatk</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">Atari Degas .pi1</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">pi1toppm</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">ppmtopi1</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">Atari Degas .pi3</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">pi3topbm</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">pbmtopi3</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">Atari compressed Spectrum file</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">spctoppm</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1"></TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">Atari uncompressed Spectrum file</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">sputoppm</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1"></TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">AutoCAD database or slide</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">sldtoppm</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">ppmtoacad</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">BBN BitGraph graphics</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1"></TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">pbmtobbnbg</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">Bennet Yee "face" file</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">ybmtopbm</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">pbmtoybm</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">Biorad confocal microscope files</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">bioradtopgm</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1"></TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">CMU window manager bitmap</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">cmuwmtopbm</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">pbmtocmuwm</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">DEC LN03+</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1"></TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">pbmtoln03</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">DEC sixel format</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1"></TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">ppmtosixel</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">DDIF format</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1"></TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">pnmtoddif</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">Encapsulated PostScript preview bitmap</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1"></TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">pbmtoepsi</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">Epson printer graphics</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1"></TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">pbmtoepson</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">FITS</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">fitstopnm</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">pnmtofits</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">GEM .img file</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">gemtopbm</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">pbmtogem</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">GIF</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">giftopnm</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">ppmtogif</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">Gemini 10X printer graphics</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1"></TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">pbmto10x</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">Gould scanner file</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">gouldtoppm</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1"></TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">GraphOn graphics (compressed)</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1"></TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">pbmtogo</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">Group 3 fax file</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">g3topbm</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">pbmtog3</TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">HIPS</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">hipstopgm</TD><TDCLASS="entry"ROWSPAN="1"COLSPAN="1"></TD></TR><TRCLASS="row"VALIGN="TOP"><TDCLASS="entry"ROWSPAN="1"COLSPAN="1">HP LaserJet format</TD><TDCLASS="entry"ROWSPAN="1"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -