| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.3//EN"> |
| 2 | <html><head><title>Tifftopnm User Manual</title></head> |
| 3 | <body> |
| 4 | <h1>tifftopnm</h1> |
| 5 | Updated: 02 January 2015 |
| 6 | <br> |
| 7 | <a href="#index">Table Of Contents</a> |
| 8 | |
| 9 | <h2>NAME</h2> |
| 10 | |
| 11 | tifftopnm - convert a TIFF file into a PNM image |
| 12 | |
| 13 | <h2 id="synopsis">SYNOPSIS</h2> |
| 14 | |
| 15 | <b>tifftopnm</b> |
| 16 | |
| 17 | [<b>-alphaout=</b>{<i>alpha-filename</i>,<b>-</b>}] |
| 18 | [<b>-headerdump</b>] |
| 19 | [<b>-verbose</b>] |
| 20 | <br> |
| 21 | [<b>-respectfillorder</b>] |
| 22 | [<b>-byrow</b>] |
| 23 | [<b>-orientraw</b>] |
| 24 | [<i>tiff-filename</i>] |
| 25 | |
| 26 | |
| 27 | <h2 id="description">DESCRIPTION</h2> |
| 28 | |
| 29 | <p>This program is part of <a href="index.html">Netpbm</a>. |
| 30 | |
| 31 | <p><b>tifftopnm</b> reads a TIFF file as input and produces a PNM image as |
| 32 | output. The type of the output file depends on the input file - if it's black |
| 33 | and white, <b>tifftopnm</b> generates a PBM image; if it's grayscale, it |
| 34 | generates a PGM image; otherwise, the output is PPM. The program tells you |
| 35 | which type it is writing. |
| 36 | |
| 37 | <p>If the TIFF file contains multiple images (multiple |
| 38 | "directories"), <b>tifftopnm</b> generates a multi-image PNM |
| 39 | output stream. Before Netpbm 10.27 (March 2005), however, it would |
| 40 | just ignore all but the first input image. |
| 41 | |
| 42 | <p>The <i>tiff-filename</i> argument names the file that contains the Tiff |
| 43 | image. If you specify "-" or don't specify this |
| 44 | argument, <b>tifftopnm</b> uses Standard Input. |
| 45 | |
| 46 | <p>In either case, before Netpbm 10.70 (March 2015), the file must be |
| 47 | seekable. That means no pipe, but any regular file is fine. In current |
| 48 | Netpbm, the file need not be seekable, but if it isn't, <b>tifftopnm</b> |
| 49 | creates a temporary regular file containing the entire image, so you must have |
| 50 | resources for that (and it may defeat your reason for using a pipe). |
| 51 | |
| 52 | <h3 id="library">TIFF Capability</h3> |
| 53 | |
| 54 | <p><b>pamtotiff</b> uses the Libtiff.org TIFF library (or whatever |
| 55 | equivalent you provide) to interpret the TIFF input. So the set of files |
| 56 | it is able to interpret is determined mostly by that library. |
| 57 | |
| 58 | <p>This program cannot read every possible TIFF file -- there are |
| 59 | myriad variations of the TIFF format. However, it does understand |
| 60 | monochrome and gray scale, RGB, RGBA (red/green/blue with transparency |
| 61 | channel), CMYK (Cyan-Magenta-Yellow-Black ink color separation), and |
| 62 | color palette TIFF files. An RGB file can have either single plane |
| 63 | (interleaved) color or multiple plane format. The program reads 1-8 |
| 64 | and 16 bit-per-sample input, the latter in either bigendian or |
| 65 | littlendian encoding. Tiff directory information may also be either |
| 66 | bigendian or littlendian. |
| 67 | |
| 68 | <p>There are many TIFF formats that <b>tifftopnm</b> can read only if |
| 69 | the image is small enough to fit in memory. <b>tifftopnm</b> uses the |
| 70 | TIFF library's TIFFRGBAImageGet() function to process the TIFF image |
| 71 | if it can get enough memory for TIFFRGBAImageGet() to store the whole |
| 72 | image in memory at once (that's what TIFFRGBAImageGet() does). If |
| 73 | not, <b>tifftopnm</b> uses a more primitive row-by-row conversion |
| 74 | strategy using the raw data returned by TIFFReadScanLine() and native |
| 75 | intelligence. That native intelligence does not know as many formats |
| 76 | as TIFFRGBAImageGet() does. And certain compressed formats simply |
| 77 | cannot be read with TIFFReadScanLine(). |
| 78 | |
| 79 | <p>Before Netpbm 10.11 (October 2002), <b>tifftopnm</b> never used |
| 80 | TIFFRGBAImageGet(), so it could not interpret many of the formats it |
| 81 | can interpret today. |
| 82 | |
| 83 | <p>There is no fundamental reason that this program could not read |
| 84 | other kinds of TIFF files even when they don't fit in memory all at |
| 85 | once. The existing limitations are mainly because no one has asked |
| 86 | for more. |
| 87 | |
| 88 | <h3 id="output">Output Image</h3> |
| 89 | |
| 90 | <p>The PNM output has the same maxval as the Tiff input, except that |
| 91 | if the Tiff input is colormapped (which implies a maxval of 65535) the |
| 92 | PNM output has a maxval of 255. Though this may result in lost |
| 93 | information, such input images hardly ever actually have more color |
| 94 | resolution than a maxval of 255 provides and people often cannot deal |
| 95 | with PNM files that have maxval > 255. By contrast, a |
| 96 | non-colormapped Tiff image that doesn't need a maxval > 255 doesn't |
| 97 | <em>have</em> a maxval > 255, so when <b>tifftopnm</b> sees a |
| 98 | non-colormapped maxval > 255, it takes it seriously and produces a |
| 99 | matching output maxval. |
| 100 | |
| 101 | <p>Another exception is where the TIFF maxval is greater than 65535, |
| 102 | which is the maximum allowed by the Netpbm formats. In that case, |
| 103 | <b>tifftopnm</b> uses a maxval of 65535, and you lose some information |
| 104 | in the conversion. |
| 105 | |
| 106 | <h2 id="options">OPTIONS</h2> |
| 107 | |
| 108 | <p>In addition to the options common to all programs based on libnetpbm |
| 109 | (most notably <b>-quiet</b>, see <a href="index.html#commonoptions"> |
| 110 | Common Options</a>), <b>tifftopnm</b> recognizes the following |
| 111 | command line options: |
| 112 | |
| 113 | <p>You may abbreviate any option to its shortest unique prefix. You may use |
| 114 | two hyphens instead of one in options. You may separate an option and |
| 115 | its value either by an equals sign or white space. |
| 116 | |
| 117 | <dl compact> |
| 118 | <dt><b>-alphaout=</b><i>alpha-filename</i> |
| 119 | |
| 120 | <dd><b>tifftopnm </b>creates a PGM file containing the alpha channel |
| 121 | values in the input image. If the input image doesn't contain a |
| 122 | transparency channel, the <i>alpha-filename</i> file contains all zero |
| 123 | (transparent) transparency values. If you don't specify <b>-alphaout</b>, |
| 124 | |
| 125 | <b>tifftopnm</b> does not generate a transparency file, and if the input |
| 126 | image has an transparency channel, <b>tifftopnm</b> simply discards it. |
| 127 | |
| 128 | <p>If you specify <b>-</b> as the filename, <b>tifftopnm</b> |
| 129 | writes the transparency output to Standard Output and discards the image. |
| 130 | |
| 131 | <p>See <b><a href="pamcomp.html">pamcomp</a></b> for one way to use |
| 132 | the transparency output file. |
| 133 | |
| 134 | <dt><b>-respectfillorder</b> |
| 135 | |
| 136 | <dd>By default, <b>tifftopnm </b> ignores the "fillorder" |
| 137 | tag in the TIFF input, which means it may incorrectly interpret the |
| 138 | image. To make it follow the spec, use this option. For a lengthy |
| 139 | but engaging discussion of why <b>tifftopnm</b> works this way and how |
| 140 | to use the <b>-respectfillorder</b> option, see the note on fillorder |
| 141 | below. |
| 142 | |
| 143 | <dt><b>-byrow</b> |
| 144 | |
| 145 | <dd>This option can make <b>tifftopnm</b> run faster. |
| 146 | |
| 147 | <p><b>tifftopnm</b> has two ways to do the conversion from Tiff to PNM, using |
| 148 | respectively two facilities of the TIFF library: |
| 149 | |
| 150 | <dl> |
| 151 | |
| 152 | <dt>Whole Image |
| 153 | |
| 154 | <dd>Decode the entire image into memory at once, using |
| 155 | <b>TIFFRGBAImageGet()</b>, then convert to PNM and output row by row. |
| 156 | |
| 157 | <dt>Row By Row |
| 158 | <dd>Read, convert, and output one row at a time |
| 159 | using <b>TIFFReadScanline()</b> |
| 160 | |
| 161 | </dl> |
| 162 | |
| 163 | <p>Whole Image is preferable because the Tiff library does more of the |
| 164 | work, which means it understands more of the Tiff format possibilities |
| 165 | now and in the future. Also, some compressed TIFF formats don't allow |
| 166 | you to extract an individual row. |
| 167 | |
| 168 | <p>Row By Row uses far less memory, which means with large images, it |
| 169 | can run in environments where Whole Image cannot and may also run |
| 170 | faster. And because Netpbm code does more of the work, it's possible |
| 171 | that it can be more flexible or at least give better diagnostic |
| 172 | information if there's something wrong with the TIFF. |
| 173 | |
| 174 | <p>The Netpbm native code may do something correctly that the TIFF |
| 175 | library does incorrectly, or vice versa. |
| 176 | |
| 177 | <p>In Netpbm, we stress function over performance, so by default we |
| 178 | try Whole Image first, and if we can't get enough memory for the |
| 179 | decoded image or <b>TIFFRGBAImageGet()</b> fails, we fall back to Row By Row. |
| 180 | But if you specify the <b>-byrow</b> option, <b>tifftopnm</b> will not |
| 181 | attempt Whole Image. If Row By Row does not work, it simply fails. |
| 182 | |
| 183 | <p>See <a href="#cmyk">Color Separation (CMYK) TIFFs</a> for a |
| 184 | description of one way Row By Row makes a significant difference in |
| 185 | your results. |
| 186 | |
| 187 | <p>Whole Image costs you precision when your TIFF image uses more than |
| 188 | 8 bits per sample. <b>TIFFRGBAImageGet()</b> converts the samples to 8 bits. |
| 189 | <b>tifftopnm</b> then scales them back to maxval 65535, but the lower |
| 190 | 8 bits of information is gone. |
| 191 | |
| 192 | <p>In many versions of the TIFF library, <b>TIFFRGBAImageGet()</b> does not |
| 193 | correctly interpret TIFF files in which the raster orientation is |
| 194 | column-major (i.e. a row of the raster is a column of the image). |
| 195 | With such a TIFF library and file, you must use <b>-byrow</b> to get |
| 196 | correct output. |
| 197 | |
| 198 | <p>Before Netpbm 10.11 (October 2002), <b>tifftopnm</b> always did Row |
| 199 | By Row. Netpbm 10.12 always tried Whole Image first. <b>-byrow</b> |
| 200 | came in with Netpbm 10.13 (January 2003). |
| 201 | |
| 202 | <dt><b>-orientraw</b> |
| 203 | |
| 204 | <dd>A TIFF stream contains raster data which can be arranged in the |
| 205 | stream various ways. Most commonly, it is arranged by rows, with the |
| 206 | top row first, and the pixels left to right within each row, but many |
| 207 | other orientations are possible. |
| 208 | |
| 209 | <p>The common orientation is the same one the Netpbm formats use, so |
| 210 | <b>tifftopnm</b> can do its jobs quite efficiently when the TIFF raster |
| 211 | is oriented that way. |
| 212 | |
| 213 | <p>But if the TIFF raster is oriented any other way, it can take a |
| 214 | considerable amount of processing for <b>tifftopnm</b> to convert it to |
| 215 | Netpbm format. |
| 216 | |
| 217 | <p><b>-orientraw</b> says to produce an output image that represents the raw |
| 218 | raster in the TIFF stream rather than the image the TIFF stream is supposed to |
| 219 | represent. In the output, the top left corner corresponds to the start of the |
| 220 | TIFF raster, the next pixel to the right is the next pixel in the TIFF raster, |
| 221 | etc. <b>tifftopnm</b> can do this easily, but you don't get the right image |
| 222 | out. You can use <b>pamflip</b> to turn the output into the image the TIFF |
| 223 | stream represents (but if you do that, you pretty much lose the benefit of |
| 224 | <b>-orientraw</b>). |
| 225 | |
| 226 | <p>With this option, <b>tifftopnm</b> always uses the Row By Row method |
| 227 | (see <b>-byrow</b>). |
| 228 | |
| 229 | <p>This option was new in Netpbm 10.42 (March 2008). Before that, |
| 230 | <b>tifftopnm</b> generally produces arbitrary results with TIFF images |
| 231 | that have an orientation other than the common one. |
| 232 | |
| 233 | <dt><b>-verbose</b> |
| 234 | |
| 235 | <dd>Print extra messages to Standard Error about the conversion. |
| 236 | |
| 237 | <dt><b>-headerdump</b> |
| 238 | |
| 239 | <dd>Also dump TIFF file information to stderr. This information may be useful |
| 240 | in debugging TIFF file conversion problems. |
| 241 | |
| 242 | </dl> |
| 243 | |
| 244 | <h2 id="notes">NOTES</h2> |
| 245 | |
| 246 | <h3 id="fillorder">Fillorder</h3> |
| 247 | |
| 248 | <p> |
| 249 | There is a piece of information in the header of a TIFF image called |
| 250 | "fillorder." The TIFF specification quite clearly states |
| 251 | that this value tells the order in which bits are arranged in a byte |
| 252 | in the description of the image's pixels. There are two options, |
| 253 | assuming that the image has a format where more than one pixel can be |
| 254 | represented by a single byte: 1) the byte is filled from most |
| 255 | significant bit to least significant bit going left to right in the |
| 256 | image; and 2) the opposite. |
| 257 | <p> |
| 258 | However, there is confusion in the world as to the meaning of |
| 259 | fillorder. Evidence shows that some people believe it has to do with |
| 260 | byte order when a single value is represented by two bytes. |
| 261 | <p> |
| 262 | These people cause TIFF images to be created that, while they use a |
| 263 | MSB-to-LSB fillorder, have a fillorder tag that says they used LSB-to-MSB. |
| 264 | A program that properly interprets a TIFF image will not end up with the |
| 265 | image that the author intended in this case. |
| 266 | <p> |
| 267 | For a long time, <b>tifftopnm</b> did not understand fillorder itself |
| 268 | and assumed the fillorder was MSB-to-LSB regardless of the fillorder |
| 269 | tag in the TIFF header. And as far as I know, there is no legitimate |
| 270 | reason to use a fillorder other than MSB-to-LSB. So users of |
| 271 | <b>tifftopnm</b> were happily using those TIFF images that had |
| 272 | incorrect fillorder tags. |
| 273 | <p> |
| 274 | So that those users can continue to be happy, <b>tifftopnm</b> today |
| 275 | continues to ignore the fillorder tag unless you tell it not to. (It |
| 276 | does, however, warn you when the fillorder tag does not say MSB-to-LSB |
| 277 | that the tag is being ignored). |
| 278 | <p> |
| 279 | If for some reason you have a TIFF image that actually has LSB-to-MSB |
| 280 | fillorder, and its fillorder tag correctly indicates that, you must |
| 281 | use the <b>-respectfillorder</b> option on <b>tifftopnm</b> to get |
| 282 | proper results. |
| 283 | <p> |
| 284 | Examples of incorrect TIFF images are at <a |
| 285 | href="ftp://weather.noaa.gov.">ftp://weather.noaa.gov.</a> They are |
| 286 | apparently created by a program called <b>faxtotiff</b>. |
| 287 | |
| 288 | <p> |
| 289 | This note was written on January 1, 2002. |
| 290 | |
| 291 | |
| 292 | <h3 id="cmyk">Color Separation (CMYK) TIFFs</h3> |
| 293 | |
| 294 | <p>Some TIFF images contain color information in CMYK form, whereas PNM |
| 295 | images use RGB. There are various formulas for converting between these |
| 296 | two forms, and <b>tifftopnm</b> can use either of two. |
| 297 | |
| 298 | <p>The TIFF library (Version 3.5.4 from libtiff.org) uses |
| 299 | Y=(1-K)*(1-B) (similar for R and G) in its TIFFRGBAImageGet() service. |
| 300 | When <b>tifftopnm</b> works in Whole Image mode, it uses that service, |
| 301 | so that's the conversion you get. |
| 302 | |
| 303 | <p>But when <b>tifftopnm</b> runs in Row By Row mode, it does not use |
| 304 | TIFFRGBAImageGet(), and you get what appears to be more useful: |
| 305 | Y=1-(B+K). This is the inverse of what <b>pnmtotiffcmyk</b> does. |
| 306 | |
| 307 | <p>See the <b>-byrow</b> option for more information on Whole Image versus |
| 308 | Row By Row mode. |
| 309 | |
| 310 | <p>Before Netpbm 10.21 (March 2004), <b>tifftopnm</b> used the |
| 311 | Y=(1-K)*(1-B) formula always. |
| 312 | |
| 313 | |
| 314 | <h2 id="seealso">SEE ALSO</h2> |
| 315 | |
| 316 | <b><a href="pnmtotiff.html">pnmtotiff</a></b>, |
| 317 | <b><a href="pnmtotiffcmyk.html">pnmtotiffcmyk</a></b>, |
| 318 | <b><a href="pamcomp.html">pamcomp</a></b>, |
| 319 | <b><a href="pnm.html">pnm</a></b> |
| 320 | |
| 321 | <h2 id="author">AUTHOR</h2> |
| 322 | |
| 323 | <p>Derived by Jef Poskanzer from tif2ras.c, which is Copyright (c) |
| 324 | 1990 by Sun Microsystems, Inc. Author: Patrick J. Naughton (<a |
| 325 | href="mailto:[email protected]">[email protected]</a>). |
| 326 | |
| 327 | <hr> |
| 328 | <h2 id="index">Table Of Contents</h2> |
| 329 | <ul> |
| 330 | <li><a href="#synopsis">SYNOPSIS</a> |
| 331 | <li><a href="#description">DESCRIPTION</a> |
| 332 | <ul> |
| 333 | <li><a href="#library">TIFF Capability</a> |
| 334 | <li><a href="#output">Output Image</a> |
| 335 | </ul> |
| 336 | <li><a href="#options">OPTIONS</a> |
| 337 | <li><a href="#notes">NOTES</a> |
| 338 | <ul> |
| 339 | <li><a href="#fillorder">Fillorder</a> |
| 340 | <li><a href="#cmyk">Color Separation (CMYK) TIFFs</a> |
| 341 | </ul> |
| 342 | <li><a href="#seealso">SEE ALSO</a> |
| 343 | <li><a href="#author">AUTHOR</a> |
| 344 | </ul> |
| 345 | </body> |
| 346 | </html> |