Lib TIFF Tools
Our basic raster map format will be
TIFF. We there for need a TIFF library to handle the images. We use the
libtiff-tools C library.

Your find the hear full documentation about the
libtiff-tools.
Table of Contents
To install the C library
libtiff-tools on a Linux operarting system, we get the package:
# apt-get install libtiff-tools
The library is provided with several use full command line scripts to handle TIFF images.
We use the following TIFF command line tools:
-
bmp2tiff
-
gif2tiff
-
ppm2tiff
-
raw2tiff
-
iff2bw
-
tiffinfo
-
tiffdump
-
titiffcmp
bmp2tiff Converter
With the command
bmp2tiff we can convert
BMP bitmap images to TIFF. The usage is:
usage: bmp2tiff [options] input.bmp [input2.bmp ...] output.tif
where options are:
-r # make each strip have no more than # rows
-c lzw[:opts] compress output with Lempel-Ziv & Welch encoding
-c zip[:opts] compress output with deflate encoding
-c jpeg[:opts]compress output with JPEG encoding
-c packbits compress output with packbits encoding
-c none use no compression algorithm on output
JPEG options:
# set compression quality level (0-100, default 75)
r output color image as RGB rather than YCbCr
For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. quality
LZW and deflate options:
# set predictor value
For example, -c lzw:2 to get LZW-encoded data with horizontal differencing
-o out.tif write output to out.tif
-h this help message
gif2tiff Converter
With the command
gif2tiff we can convert
GIF images to TIFF. The usage ist:
usage: gif2tiff [options] input.gif output.tif
where options are:
-r # make each strip have no more than # rows
-c lzw[:opts] compress output with Lempel-Ziv & Welch encoding
-c zip[:opts] compress output with deflate encoding
-c packbits compress output with packbits encoding
-c none use no compression algorithm on output
LZW and deflate options:
# set predictor value
For example, -c lzw:2 to get LZW-encoded data with horizontal differencing
ppm2tiff Converter
With
ppm2tiff we can convert
PPM portable bixel map into TIFF. The usage is:
usage: ppm2tiff [options] input.ppm output.tif
where options are:
-r # make each strip have no more than # rows
-R # set x&y resolution (dpi)
-c jpeg[:opts] compress output with JPEG encoding
-c lzw[:opts] compress output with Lempel-Ziv & Welch encoding
-c zip[:opts] compress output with deflate encoding
-c packbits compress output with packbits encoding (the default)
-c g3[:opts] compress output with CCITT Group 3 encoding
-c g4 compress output with CCITT Group 4 encoding
-c none use no compression algorithm on output
JPEG options:
# set compression quality level (0-100, default 75)
r output color image as RGB rather than YCbCr
LZW and deflate options:
# set predictor value
For example, -c lzw:2 to get LZW-encoded data with horizontal differencing

For other image formats, we can use for example
convert to convert first the
image into
BMP,
GIF or
PPM. The command line tool
convert is provided the
ImageMagic
open source software. Even if we don't have a graphical X11 Window System installed on the Linux server,
we can get the
convert command by installing the package
imagemagick.
raw2tiff Converter
With the command
raw2tiff we can convert
RAW image data into TIFF. This can be use full if we compute the raster raw
data witch must displaced as raster map. The usage is:
usage: raw2tiff [options] input.raw output.tif
where options are:
-L input data has LSB2MSB bit order (default)
-M input data has MSB2LSB bit order
-r # make each strip have no more than # rows
-H # size of input image file header in bytes (0 by default)
-w # width of input image in pixels
-l # length of input image in lines
-b # number of bands in input image (1 by default)
-d data_type type of samples in input image
where data_type may be:
byte 8-bit unsigned integer (default)
short 16-bit unsigned integer
long 32-bit unsigned integer
sbyte 8-bit signed integer
sshort 16-bit signed integer
slong 32-bit signed integer
float 32-bit IEEE floating point
double 64-bit IEEE floating point
-p photo photometric interpretation (color space) of the input image
where photo may be:
miniswhite white color represented with 0 value
minisblack black color represented with 0 value (default)
rgb image has RGB color model
cmyk image has CMYK (separated) color model
ycbcr image has YCbCr color model
cielab image has CIE L*a*b color model
icclab image has ICC L*a*b color model
itulab image has ITU L*a*b color model
-s swap bytes fetched from input file
-i config type of samples interleaving in input image
where config may be:
pixel pixel interleaved data (default)
band band interleaved data
-c lzw[:opts] compress output with Lempel-Ziv & Welch encoding
-c zip[:opts] compress output with deflate encoding
-c jpeg[:opts] compress output with JPEG encoding
-c packbits compress output with packbits encoding
-c none use no compression algorithm on output
JPEG options:
# set compression quality level (0-100, default 75)
r output color image as RGB rather than YCbCr
For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. quality
LZW and deflate options:
# set predictor value
For example, -c lzw:2 to get LZW-encoded data with horizontal differencing
-o out.tif write output to out.tif
-h this help message
Color Scale and Gray Scale
A RGB or Palette color TIFF image is converted to a greyscale image by combining percentages of the
red, green, and blue channels. By default, output samples are created by taking 28% of the red channel,
59% of the green channel, and 11% of the blue channel:
grey = (28 * R + 59 * G + 11 * B ) / 100 = r * R + g * G + b * B
with
r = 28%,
g = 59% and
b = 11%.
The greyscale is device independant, because we don't considere any
Gamma Correction for the color model.
A map with greyscale
[grey_0, garey_1] illustrates some scalar value range
[V_0, V_1]. The greyscale should match
linearly the scalar value, i.e.:
grey_x = grey_0 + x * (grey_1 - grey_0)
so that for
x = 0 we get
grey_0, and for
x = 1 we get
grey_1. Therefor we must have
grey_x = grey_0 + x * (grey_1 - grey_0)
= r * R_0 + g * R_0 + b * B_0 + x * [ () - () ]
tiff2bw Color to Grayscale Converter
With the command
tiff2bw we can convert a color TIFF to a gray scale TIFF. This is use full if we have some falls color
raster map, from witch we wont to get the numerical value of a pixel, for example the elevation from a falls color
hypsography. The usage is:
usage: tiff2bw [options] input.tif output.tif
where options are:
-R % use #% from red channel
-G % use #% from green channel
-B % use #% from blue channel
-r # make each strip have no more than # rows
-c lzw[:opts] compress output with Lempel-Ziv & Welch encoding
-c zip[:opts] compress output with deflate encoding
-c packbits compress output with packbits encoding
-c g3[:opts] compress output with CCITT Group 3 encoding
-c g4 compress output with CCITT Group 4 encoding
-c none use no compression algorithm on output
LZW and deflate options:
# set predictor value
For example, -c lzw:2 to get LZW-encoded data with horizontal differencing
tiffinfo TIFF Tag Print
With the command
tiffinfo we can print the TIFF tag values.
The usage is:
usage: tiffinfo [options] input...
where options are:
-D read data
-i ignore read errors
-c display data for grey/color response curve or colormap
-d display raw/decoded image data
-f lsb2msb force lsb-to-msb FillOrder for input
-f msb2lsb force msb-to-lsb FillOrder for input
-j show JPEG tables
-o offset set initial directory offset
-r read/display raw image data instead of decoded data
-s display strip offsets and byte counts
-w display raw data in words rather than bytes
-z enable strip chopping
-# set initial directory (first directory is # 0)
tiffdump TIFF Tag Verbose Print
With the command
tiffdump we can print a verbose version of TIFF tag values.
The usage is:
usage: tiffdump [-h] [-o offset] [-m maxitems] file.tif ...
tiffcmp TIFF Tag Compare
With
tiffcmp we can compare the TIFF tag structure a values from to TIFF files.
The usage is:
usage: tiffcmp [options] file1 file2
where options are:
-l list each byte of image data that differs between the files
-z # list specified number of bytes that differs between the files
-t ignore any differences in directory tags
More TIFF Comand Line Tools
There some more TIFF command line tools:
-
tiffset set a tag field and values in a TIFF header
-
tiffcp combines one or more files created
-
tiffsplit split a multi-image TIFF into single-image TIFF files
Reading a TIFF File
Writing a TIFF File
--
RalfSchaer - 2009-12-31