.TL Tifftopnm User Manual .SH 1 tifftopnm .LP Updated: 27 March 2005 .br Table Of Contents .SH 2 NAME .LP tifftopnm - convert a TIFF file into a PNM image .SH 2 SYNOPSIS .LP \fBtifftopnm\fR [\fB-alphaout=\fR{\fIalpha-filename\fR,\fB-\fR}] [\fB-headerdump\fR] .br [\fB-respectfillorder\fR] [\fB-byrow\fR] [\fItiff-filename\fR] .LP You may abbreviate any option to its shortest unique prefix. You may use two hyphens instead of one in options. You may separate an option and its value either by an equals sign or white space. .SH 2 DESCRIPTION .LP .LP This program is part of Netpbm. .LP \fBtifftopnm\fR reads a TIFF file as input and produces a PNM image as output. The type of the output file depends on the input file - if it's black & white, generates a PBM image; if it's grayscale, generates a PGM image; otherwise, a PPM image. The program tells you which type it is writing. .LP If the TIFF file contains multiple images (multiple "directories,"), \fBtifftopnm\fR generates a multi-image PNM output stream. Before Netpbm 10.27 (March 2005), however, it would just ignore all but the first input image. .LP This program cannot read every possible TIFF file -- there are myriad variations of the TIFF format. However, it does understand monochrome and gray scale, RGB, RGBA (red/green/blue with alpha channel), CMYK (Cyan-Magenta-Yellow-Black ink color separation), and color palette TIFF files. An RGB file can have either single plane (interleaved) color or multiple plane format. The program reads 1-8 and 16 bit-per-sample input, the latter in either bigendian or littlendian encoding. Tiff directory information may also be either bigendian or littlendian. .LP There are many TIFF formats that \fBtifftopnm\fR can read only if the image is small enough to fit in memory. \fBtifftopnm\fR uses the TIFF library's TIFFRGBAImageGet() function to process the TIFF image if it can get enough memory for TIFFRGBAImageGet() to store the whole image in memory at once (that's what TIFFRGBAImageGet() does). If not, \fBtifftopnm\fR uses a more primitive row-by-row conversion strategy using the raw data returned by TIFFReadScanLine() and native intelligence. That native intelligence does not know as many formats as TIFFRGBAImageGet() does. And certain compressed formats simply cannot be read with TIFFReadScanLine(). .LP Before Netpbm 10.11 (October 2002), \fBtifftopnm\fR never used TIFFRGBAImageGet(), so it could not interpret many of the formats it can interpret today. .LP There is no fundamental reason that this program could not read other kinds of TIFF files even when they don't fit in memory all at once. The existing limitations are mainly because no one has asked for more. .LP The PNM output has the same maxval as the Tiff input, except that if the Tiff input is colormapped (which implies a maxval of 65535) the PNM output has a maxval of 255. Though this may result in lost information, such input images hardly ever actually have more color resolution than a maxval of 255 provides and people often cannot deal with PNM files that have maxval > 255. By contrast, a non-colormapped Tiff image that doesn't need a maxval > 255 doesn't have a maxval > 255, so when \fBtifftopnm\fR sees a non-colormapped maxval > 255, it takes it seriously and produces a matching output maxval. .LP Another exception is where the TIFF maxval is greater than 65535, which is the maximum allowed by the Netpbm formats. In that case, \fBtifftopnm\fR uses a maxval of 65535, and you lose some information in the conversion. .LP The \fItiff-filename\fR argument names the regular file that contains the Tiff image. If you specify "-" or don't specify this argument, \fBtfftopnm\fR uses Standard Input. In either case, the file must be seekable. That means no pipe, but any regular file is fine. .SH 2 OPTIONS .LP .RS .IP "\fB-alphaout=\fR\fIalpha-filename\fR" \fBtifftopnm \fRcreates a PGM file containing the alpha channel values in the input image. If the input image doesn't contain an alpha channel, the \fIalpha-filename\fR file contains all zero (transparent) alpha values. If you don't specify \fB-alphaout\fR, \fBtifftopnm\fR does not generate an alpha file, and if the input image has an alpha channel, \fBtifftopnm\fR simply discards it. .LP If you specify \fB-\fR as the filename, \fBtifftopnm\fR writes the alpha output to Standard Output and discards the image. .LP See \fBpamcomp\fR for one way to use the alpha output file. .IP "\fB-respectfillorder\fR" By default, \fBtifftopnm \fR ignores the "fillorder" tag in the TIFF input, which means it may incorrectly interpret the image. To make it follow the spec, use this option. For a lengthy but engaging discussion of why \fBtifftopnm\fR works this way and how to use the \fB-respectfillorder\fR option, see the note on fillorder below. .IP "\fB-byrow\fR" This option can make \fBtifftopnm\fR run faster. .LP \fBtifftopnm\fR has two different ways to do the conversion from Tiff to PNM, using two different facilities of the TIFF library: .RS .IP "Whole Image" Decode the entire image into memory at once, using TIFFRGBAImageGet(), then convert to PNM and output row by row. .IP "Row By Row" Read, convert, and output one row at a time using TIFFReadScanline(). .RE .LP Whole Image is preferable because the Tiff library does more of the work, which means it understands more of the Tiff format possibilities now and in the future. Also, some compressed TIFF formats don't allow you to extract an individual row. .LP Row By Row uses far less memory, which means with large images, it can run in environments where Whole Image cannot and may also run faster. And because Netpbm code does more of the work, it's possible that it can be more flexible or at least give better diagnostic information if there's something wrong with the TIFF. .LP In Netpbm, we stress function over performance, so by default we try Whole Image first, and if we can't get enough memory for the decoded image or TIFFRGBAImageGet() fails, we fall back to Row By Row. But if you specify the \fB-byrow\fR option, \fBtifftopnm\fR will not attempt Whole Image. If Row By Row does not work, it simply fails. .LP See Color Separation (CMYK) TIFFs for a description of one way Row By Row makes a significant difference in your results. .LP Whole Image costs you precision when your TIFF image uses more than 8 bits per sample. TIFFRGBAImageGet() converts the samples to 8 bits. \fBtifftopnm\fR then scales them back to maxval 65535, but the lower 8 bits of information is gone. .LP Before Netpbm 10.11 (October 2002), \fBtifftopnm\fR always did Row By Row. Netpbm 10.12 always tried Whole Image first. \fB-byrow\fR came in with Netpbm 10.13 (January 2003). .IP "\fB-headerdump\fR" Dump TIFF file information to stderr. This information may be useful in debugging TIFF file conversion problems. .RE .SH 2 NOTES .LP .SH 3 Fillorder .LP .LP There is a piece of information in the header of a TIFF image called "fillorder." The TIFF specification quite clearly states that this value tells the order in which bits are arranged in a byte in the description of the image's pixels. There are two options, assuming that the image has a format where more than one pixel can be represented by a single byte: 1) the byte is filled from most significant bit to least significant bit going left to right in the image; and 2) the opposite. .LP However, there is confusion in the world as to the meaning of fillorder. Evidence shows that some people believe it has to do with byte order when a single value is represented by two bytes. .LP These people cause TIFF images to be created that, while they use a MSB-to-LSB fillorder, have a fillorder tag that says they used LSB-to-MSB. A program that properly interprets a TIFF image will not end up with the image that the author intended in this case. .LP For a long time, \fBtifftopnm\fR did not understand fillorder itself and assumed the fillorder was MSB-to-LSB regardless of the fillorder tag in the TIFF header. And as far as I know, there is no legitimate reason to use a fillorder other than MSB-to-LSB. So users of \fBtifftopnm\fR were happily using those TIFF images that had incorrect fillorder tags. .LP So that those users can continue to be happy, \fBtifftopnm\fR today continues to ignore the fillorder tag unless you tell it not to. (It does, however, warn you when the fillorder tag does not say MSB-to-LSB that the tag is being ignored). .LP If for some reason you have a TIFF image that actually has LSB-to-MSB fillorder, and its fillorder tag correctly indicates that, you must use the \fB-respectfillorder\fR option on \fBtifftopnm\fR to get proper results. .LP Examples of incorrect TIFF images are at ftp://weather.noaa.gov. They are apparently created by a program called \fBfaxtotiff\fR. .LP This note was written on January 1, 2002. .SH 3 Color Separation (CMYK) TIFFs .LP .LP Some TIFF images contain color information in CMYK form, whereas PNM images use RGB. There are various formulas for converting between these two forms, and \fBtifftopnm\fR can use either of two. .LP The TIFF library (Version 3.5.4 from libtiff.org) uses Y=(1-K)*(1-B) (similar for R and G) in its TIFFRGBAImageGet() service. When \fBtifftopnm\fR works in Whole Image mode, it uses that service, so that's the conversion you get. .LP But when \fBtifftopnm\fR runs in Row By Row mode, it does not use TIFFRGBAImageGet(), and you get what appears to be more useful: Y=1-(B+K). This is the inverse of what \fBpnmtotiffcmyk\fR does. .LP See the \fB-byrow\fR option for more information on Whole Image versus Row By Row mode. .LP Before Netpbm 10.21 (March 2004), \fBtifftopnm\fR used the Y=(1-K)*(1-B) formula always. .SH 2 SEE ALSO .LP \fBpnmtotiff\fR, \fBpnmtotiffcmyk\fR, \fBpamcomp\fR, \fBpnm\fR .SH 2 AUTHOR .LP .LP Derived by Jef Poskanzer from tif2ras.c, which is Copyright (c) 1990 by Sun Microsystems, Inc. Author: Patrick J. Naughton (naughton@wind.sun.com). .br \l'5i' .SH 2 Table Of Contents .LP .IP \(bu NAME .IP \(bu SYNOPSIS .IP \(bu DESCRIPTION .IP \(bu OPTIONS .IP \(bu NOTES .IP \(bu Fillorder .IP \(bu Color Separation (CMYK) TIFFs .LP .IP \(bu SEE ALSO .IP \(bu AUTHOR .LP