pnmtotiff
Convert PNM image format to TIFF
TLDR
View documentation for the current command
SYNOPSIS
pnmtotiff [options] [pnmfile]
PARAMETERS
-none
Specifies no compression for the output TIFF file.
-packbits
Uses PackBits compression, a lossless RLE (Run-Length Encoding) compression method.
-lzw
Applies LZW (Lempel-Ziv-Welch) compression, a lossless compression algorithm.
-zip
Utilizes Deflate (ZIP) compression, a lossless compression algorithm.
-jpeg
Applies JPEG compression, a lossy compression method suitable for photographic images. Quality cannot be controlled directly by this option.
-g4
Applies Group 4 Fax compression, a lossless compression method specifically for monochrome (1-bit) images. Input must be PBM or converted to monochrome.
-monochrome
Forces the output TIFF to be 1-bit black and white (monochrome). Color and grayscale information will be lost.
-grayscale
Forces the output TIFF to be 8-bit grayscale. Color information will be lost if input is PPM.
-truecolor
Forces the output TIFF to be 24-bit RGB truecolor. Only relevant for PPM input.
-alpha
Includes an alpha channel in the output TIFF. Only applicable when input is PPM.
-rowsperstrip <n>
Sets the number of rows per strip in the TIFF file. A strip is a block of image data.
-xresolution <x>
Sets the X (horizontal) resolution of the image in pixels per unit.
-yresolution <y>
Sets the Y (vertical) resolution of the image in pixels per unit.
-resolutionunit <unit>
Sets the unit for resolution, e.g., inch, cm, or none. Defaults to inch.
-description <text>
Sets the TIFF 'ImageDescription' tag to the specified text.
-datetime <YYYY:MM:DD HH:MM:SS>
Sets the TIFF 'DateTime' tag to the specified date and time string.
-documentname <name>
Sets the TIFF 'DocumentName' tag to the specified name.
-pagename <name>
Sets the TIFF 'PageName' tag to the specified name.
-software <name>
Sets the TIFF 'Software' tag to the specified software name.
-predictor <n>
Sets the predictor for LZW or Deflate compression. Common values are 1 (no prediction), 2 (horizontal differencing).
-tiled
Writes the TIFF file using tiles instead of strips. Requires -tilewidth and -tilelength.
-tilewidth <w>
Sets the width of tiles when -tiled is used.
-tilelength <l>
Sets the length (height) of tiles when -tiled is used.
-standard
Uses the standard TIFF byte order (big-endian). This is usually the default.
-lsb
Writes the TIFF with least-significant byte first (little-endian) byte order.
-msb
Writes the TIFF with most-significant byte first (big-endian) byte order.
-multipage
Experimental: Creates a multi-page TIFF. Each PNM input will be a separate page.
-nofillorder
Does not specify the TIFF 'FillOrder' tag. Useful for compatibility with some older or non-standard readers.
DESCRIPTION
pnmtotiff is a powerful utility from the Netpbm image processing suite, designed to convert PNM (Portable Anymap) image files into the TIFF (Tagged Image File Format). It supports all PNM sub-formats: PPM (Portable Pixmap) for color images, PGM (Portable Graymap) for grayscale, and PBM (Portable Bitmap) for monochrome images.
The command offers extensive control over the output TIFF file, including various compression methods (e.g., LZW, PackBits, JPEG, Deflate/ZIP, Group 4 Fax), resolution settings, and metadata tags like description, date, and software. Users can specify the output image type (monochrome, grayscale, or truecolor RGB), even adding an alpha channel for PPM input.
Typically, pnmtotiff reads image data from standard input (allowing it to be easily chained with other Netpbm tools) and writes the resulting TIFF image to standard output. This makes it a versatile component in command-line image processing workflows.
CAVEATS
- Input Format: pnmtotiff strictly requires Netpbm format (PPM, PGM, or PBM) as input. Attempting to convert other image formats directly will result in an error. Use other Netpbm tools like anytopnm to convert non-PNM formats first.
- Lossy Compression: When using -jpeg compression, quality settings are not directly controllable by pnmtotiff and may result in lossy compression artifacts.
- Monochrome/Grayscale Conversion: Converting color images to monochrome (-monochrome) or grayscale (-grayscale) will irreversibly discard color information.
- Experimental Features: Options like -multipage might be experimental or have limited support in some TIFF readers.
- Dependencies: pnmtotiff relies on the libtiff library for its functionality.
STANDARD INPUT/OUTPUT
By default, pnmtotiff reads its PNM input from standard input (stdin) if no pnmfile argument is provided. It writes the resulting TIFF image to standard output (stdout). This design allows for flexible piping with other commands, such as: cat image.ppm | pnmtotiff -lzw > image.tiff.
DEFAULT BEHAVIOR
If no options are specified, pnmtotiff will attempt to create a TIFF file that closely matches the input PNM. For PPM input, it typically produces 24-bit RGB. For PGM, 8-bit grayscale. For PBM, 1-bit monochrome. Default compression is usually LZW or no compression depending on the libtiff version and compile-time options.
HISTORY
pnmtotiff is a key component of the Netpbm image processing package. Netpbm itself is a collection of graphics programs and a programming library that evolved from the earlier Pbmplus package, originally created by Jef Poskanzer in the late 1980s. Bryan Henderson has been the primary maintainer and developer of Netpbm since the mid-1990s.
The command's lineage reflects a common philosophy in Unix tools: small, focused utilities that do one thing well and can be chained together. Its integration within Netpbm allows it to seamlessly convert images from various sources (via anytopnm) into the versatile TIFF format, making it a foundational tool for image conversion in scripting and automated workflows for decades.