tiff2bw Command in Linux



The tiff2bw command in Linux converts a color TIFF (Tagged Image File Format) image into a black-and-white (monochrome) TIFF image. It converts an RGB or Palette TIFF image to greyscale by combining the red, green, and blue channels. By default, it uses 28% red, 59% green, and 11% blue channels — making it useful for simplifying images by removing color.

Table of Contents

Here is a comprehensive guide to the options available with the tiff2bw command −

Installation of tiff2bw Command

The tiff2bw command is part of the libtiff-tools package in Linux. Ensure the package is installed before using the command. To install it on Ubuntu, Kali Linux, Raspberry Pi OS, Debian, and other Debian-based distributions, use the following command −

sudo apt install libtiff-tools

To install it on Arch Linux, use the command given below −

sudo pacman -S libtiff

To install libtiff-tools on Fedora, use the following command −

sudo dnf install libtiff-tools

To verify the installation of the tiff2bw command, check its binary using the which command −

which tiff2bw
tiff2bw Command in Linux

Syntax of tiff2bw Command

The syntax of the tiff2bw command in Linux is as follows −

tiff2bw [options] [input.tiff] [output.tiff]

In the above syntax, the [options] field is used to specify various options to change the output behavior. The [input.tiff] and [output.tiff] fields are used to specify the input and output TIFF image files.

tiff2bw Command Options

The options of the Linux tiff2bw command are listed below −

Option Description
-c Specify a compression scheme when writing image data: none (no compression), packbits (PackBits), zip (Deflate), g3 (CCITT Group 3), g4 (CCITT Group 4), lzw (Lempel-Ziv & Welch, default).
-r Write data with a specified number of rows per strip (default is approximately 8 kilobytes per strip).
-R Specify the percentage of the red channel to use (default 28).
-G Specify the percentage of the green channel to use (default 59).
-B Specify the percentage of the blue channel to use (default 11).

Examples of tiff2bw Command in Linux

This section discusses how to use the tiff2bw command in Linux with examples −

  • Converting an RGB TIFF to Greyscale
  • Converting an RGB TIFF to Greyscale using a Compression Scheme
  • Specifying the Custom Number of Rows per Strip
  • Specifying the Custom Channel Percentage

Convert an RGB TIFF to Greyscale

To convert an RGB or palette TIFF image file to greyscale, use the tiff2bw command in the following way −

tiff2bw input.tif output.tif
tiff2bw Command in Linux2

The above command uses default channel percentages: 28% red, 59% green, and 11% blue.

tiff2bw Command in Linux3

Converting an RGB TIFF to Greyscale using a Compression Scheme

To convert an RGB or palette TIFF image file to greyscale using a compression scheme, use the -c option followed by the compression scheme type −

tiff2bw -c zip input.tif output.tif

Other compression schemes are listed below −

  • packbits
  • g3
  • g4
  • lzw

Specifying the Custom Number of Rows per Strip

The default number of rows per strip is approximately 8KB per strip. To modify the number of rows per strip, use the -r option with the tiff2bw command −

tiff2bw -r 16 input.tif output.tif

Specifying the Custom Channel Percentage

To specify the custom percentages for each color channel, use the -R, -G, -B options:

tiff2bw -R 30 -G 50 -B 20 input.tif output.tif

Conclusion

The tiff2bw command in Linux provides a simple method to convert color TIFF images into black-and-white (monochrome) TIFF images. By default, it converts RGB or Palette images to greyscale using specific percentages of the red, green, and blue channels.

The tiff2bw command offers options for customizing the channel percentages, specifying compression schemes, and adjusting the number of rows per strip in the output file.

Advertisements