tiffdither Command in Linux



The tiffdither command in Linux converts a greyscale TIFF image into a black-and-white (bilevel) image using dithering. This is especially useful for preparing images for devices that support only monochrome output, such as certain printers or fax systems.

Table of Contents

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

Prerequisites of tiffdither Command

The tiffdither command is part of the libtiff-tools package in Linux. Make sure 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 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 tiffdither command, check its binary using the which command −

which tiffdither
tiffdither Command in Linux1

Syntax of tiffdither Command

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

tiffdither [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.

tiffdither Command Options

The options of the Linux tiffdither command are listed below −

Option Description
-c

Specify compression for output. Supported types: none, packbits, lzw, zip, g3, g4.

LZW: use :1 (no differencing) or :2 (horizontal differencing).

G3 (bilevel only): use :1d, :2d, :fill for encoding and alignment (-c g3:2d:fill).

Defaults to Compression tag from source if omitted.

-f Set bit fill order: lsb2msb or msb2lsb. Defaults to original file’s order.
-t Set dithering threshold (default: 128). Controls brightness cutoff for binarization.

Examples of tiffdither Command in Linux

This section explores how to use the tiffdither command in Linux with examples −

  • Converting a TIFF File to Bilevel
  • Converting a TIFF File to Bilevel using Compression
  • Setting Bit Fill Order
  • Adjusting Threshold Settings

Converting a TIFF File to Bilevel

To convert a greyscale TIFF image file to bilevel using the default settings (threshold = 128, compression = from source), use the tiffdither command followed by the filename −

tiffdither sample.tiff output.tiff
tiffdither Command in Linux2

The difference between the sample and output image is shown in the following image −

tiffdither Command in Linux3

Converting a TIFF File to Bilevel using Compression

To convert a TIFF image to bilevel with compression, use the -c option. The following command applies LZW compression with no horizontal differencing.

tiffdither -c lzw sample.tiff output.tiff

To apply CCITT Group 3 compression with 2D encoding and byte-aligned EOL codes (for bilevel images only), use −

tiffdither -c g3:2d:fill sample.tiff output.tiff

In the same way, to apply CCITT Group 4 compression (for bilevel images only), use the tiffdither command in the following way −

tiffdither -c g4 sample.tiff output.tiff

Setting Bit Fill Order

To set the bit fill order to write the output data, use the -f option −

tiffdither -f lsb2msb sample.tiff output.tiff

Specifying -f lsb2msb sets the FillOrder tag to LSB2MSB; -f msb2lsb sets it to MSB2LSB.

Adjusting Threshold Settings

To adjust the threshold settings, use the -t option with the tiffdither command −

tiffdither -t 100 sample.tiff output.tiff

If the threshold is low, more pixels will become black, which is good for light images. Similarly, if the threshold is higher, fewer pixels become black, which may preserve detail in darker images.

Conclusion

The tiffdither command in Linux is a helpful tool for converting greyscale TIFF images to black-and-white using dithering. It is useful for preparing images for devices that support only monochrome output.

This tutorial covered how to install the required package, the basic syntax, the available options, and examples of using the command with different settings like compression, fill order, and threshold adjustments.

Advertisements