From: Robert G. B. <rg...@ph...> - 2001-02-13 12:15:07
|
On Tue, 13 Feb 2001, Gerhard Fuernkranz wrote: > David Paschal wrote: > > > > James Klicman wrote: > > > I have succeeded in scanning BILEVEL_THRESHOLD/NO_COMPRESSION > > > and then creating a viewable .pgm file with the data. > > A very simple, easy graphics file format. > Actually it is a whole family consisting of > > "pbm" -> bitmap with depth=1, each pixel can be > black/white (-> e.g. a typical Fax) > "pgm" -> a grayscale picture > "ppm" -> a RGB color picture (truecolor with RGB > for each pixel, not with colormap/indexed > like a GIF) > "pnm" -> used to denote the family, i.e. any of > the above three > > There also exist the pbmplus tools for manipulating > these file types, see /usr/X11R6/bin/*{pbm,pgm,ppm,pnm}* > > Gerhard Indeed, a lot of those tools are already in place and automatically used in the printer filters, at least for a RH system. Once you get it into a p?m format, you have a number of tools for scaling, rotating, and the like. RH's strategy appears to be "get an arbitrary format into pnm, then convert pnm to ps, then print (usually using ghostscript printer filters)." See: rgb@ganesh|T:120>dir /usr/lib/rhs/rhs-printfilters/ bmp-to-pnm.fpi* gif-to-pnm.fpi* pnm-to-ps.fpi* tiff-to-pnm.fpi* dvi-to-ps.fpi* jpeg-to-pnm.fpi* rast-to-pnm.fpi* troff-to-ps.fpi* where in these filters many of the tools are demonstrated in pipes. A single example. If you have a digital camera and take a lot of pictures, you probably want to turn the hi-res jpegs into low-res, rescaled, possibly rotated gifs to stick up on your website. Here is a fragment from a little perl script I wrote to help me make this conversion: $command = "cat $INFILE | djpeg -pnm | pnmscale $scale | pnmrotate $rotate | ppmquant 256 | ppmtogif - > $OUTFILE"; if($verbose){ print "$command\n"; } system($command); djpeg converts jpeg to pnm (among others -- it will convert straight to gif but not allow scaling and rotation). pnmscale and pnmrotate scale and rotate the "pixel any map" (pnm). ppmquant fixes the colormap depth -- useful if you don't want to exhaust the colormap of a low-res 8 bit display on an unknown browser somewhere. Finally ppmtogif does the final conversion to gif. Using a tool like this (with obvious perl wrapping it and setting the variables, full program available on request) allows one to convert a whole directory of jpegs with a simple shell loop, and is often a lot easier and faster to use than cranking up a whole GUI (e.g. xv or eeyes or gimp or whatever) just to do a simple rotation and scaling. rgb -- Robert G. Brown http://www.phy.duke.edu/~rgb/ Duke University Dept. of Physics, Box 90305 Durham, N.C. 27708-0305 Phone: 1-919-660-2567 Fax: 919-660-2525 email:rg...@ph... |