bmp2tiff Command in Linux



The bmp2tiff is a command-line utility that converts Microsoft Windows Device Independent Bitmap (BMP) image files to Tagged Image File Format (TIFF) files. It takes a BMP file as input and produces a corresponding TIFF file.

If you specify multiple input BMP files, bmp2tiff can create a multipage TIFF output file. Each page in the output TIFF corresponds to one of the input BMP files.

By default, the TIFF image created by bmp2tiff has the following features −

  • Data Samples Packed − The image data is stored in a packed arrangement. (PlanarConfiguration=1).
  • Compression − The image is compressed using the PackBits algorithm. (Compression=32773).
  • Strip Size − Each strip (a portion of the image) is no more than 8 kilobytes in size.

You can override or explicitly specify different options to customize the output TIFF image. For instance, you can choose a different compression scheme, adjust the strip size, and more.

Table of Contents

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

Syntax of bmp2tiff Command

The following is the general syntax for the bmp2tiff command −

bmp2tiff [ options ] input.bmp [input2.bmp ...] output.tiff

Here −

  • bmp2tiff − The command itself.
  • [ options ] − Optional parameters you can specify to customize the conversion process. For example, you can choose a compression scheme or adjust the strip size.
  • input.bmp [input2.bmp ...] − One or more input BMP files. You can specify multiple BMP files, and each will contribute to a separate page in the output TIFF file (creating a multipage TIFF).
  • output.tiff − The name of the output TIFF file that will be generated.

bmp2tiff Command Options

The following are options available for bmp2tiff command −

Tag Description
-c none No compression.
-c packbits Uses the PackBits compression algorithm (the default).
-c jpeg Applies baseline JPEG compression.
-c zip Utilizes the Deflate compression algorithm.
-c lzw Implements Lempel-Ziv & Welch compression.
-r <number> Specifies the number of rows per strip. By default, the number of rows per strip is selected to create approximately 8-kilobyte strips.

Examples of bmp2tiff Command in Linux

In this section, we’ll look at some examples of the bmp2tiff command with different options. To use the following examples, ensure you have sudo or root privileges.

  • Convert a single BMP file to a TIFF file
  • Convert multiple BMP files into a multipage TIFF file
  • No Compression
  • PackBits Compression
  • JPEG Compression
  • Deflate Compression
  • Lempel-Ziv and Welch Compression
  • Setting Rows per Strip

Convert a single BMP file to a TIFF file

To convert a BMP file to a TIFF file, you can use the bmp2tiff command-line utility −

Convert single BMP file to TIFF file

Convert multiple BMP files into a multipage TIFF file

To create a multipage TIFF file from multiple BMP files, you can use the following syntax −

bmp2tiff input1.bmp input2.bmp input3.bmp multipage_output.tiff
Convert multiple BMP  into multipage TIFF

No Compression

To create a TIFF file (output.tiff) from the BMP image (input.bmp) without applying any compression, you can simply use the bmp2tiff command with the "-c" none option −

No Compression 1

No Compression 2

PackBits Compression

PackBits is a fast and simple compression scheme used to encode data at run-length. Apple introduced PackBits with the release of MacPaint on the Macintosh computer.

This compression method can be used in TIFF files and is also employed in TGA files (treating data as pixels instead of bytes). PackBits is a common compression method used across various systems.

To convert a Microsoft Windows Device Independent Bitmap (BMP) image file to a TIFF (Tagged Image File Format) file, you can use the bmp2tiff command with the "-c" packbits option −

bmp2tiff -c packbits input.bmp output.tiff
PackBits Compression

JPEG Compression

JPEG (Joint Photographic Experts Group) is a lossy compression technique frequently used for photographic images.

This compression method allows you to achieve high ratios by discarding some image data, which can result in reduced image quality. When using JPEG compression, you can control the compression level (quality) to balance file size and image fidelity.

The bmp2tiff command allows you to convert a Microsoft Windows Device Independent Bitmap (BMP) image file to a TIFF (Tagged Image File Format) file using the JPEG compression algorithm. To get started, you can use the following syntax −

bmp2tiff -c jpeg input.bmp output.tiff 
JPEG Compression

Deflate Compression

The Deflate compression method, also known as ZIP compression, is used to convert BMP (bitmap) images to TIFF (Tagged Image File Format).

Deflate combines elements of LZ77, which recognizes and stores repeated data sequences) and Huffman coding, which assigns variable-length codes based on symbol frequency.

Deflate achieves lossless compression by replacing duplicate strings with pointers and optimizing symbol representation. To use this compression method, you can simply run the following command −

bmp2tiff -c zip input.bmp output.tiff
Deflate Compression

Lempel-Ziv and Welch Compression

LZW is a lossless compression algorithm extensively used for image data. This compression technique reduces the file size without compromising image quality.

You can use the bmp2tiff command to convert a BMP image file (input.bmp) to a TIFF image file (output.tiff) using Lempel-Zi and Welch (LZW) compression. Here is how you can get started −

bmp2tiff -c lzw input.bmp output.tiff 
Lempel-Ziv and Welch Compression

Setting Rows Per Strip

In a TIFF file, the image data is divided into strips (or tiles), which are rectangular blocks of pixels. The "rows per strip" parameter determines how many rows of pixels are included in each strips

The choice of rows per strip affects both file size and performance during reading and writing. Smaller strips (fewer rows per strip) result in more strips, which can be beneficial for partial loading and editing.

Larger strips (more rows per strip) reduce the number of strips but may lead to inefficiencies if only part of the image needs to be accessed.

To set up the rows per trip parameter, you can simply use the following syntax −

bmp2tiff -r 30 input.bmp output.tiff

The "-r" option in the above command specifies the custom number of rows per strip for the output TIFF file. For instance, -r 30 indicates that each strip in the TIFF file will contain 30 rows of image data. This parameter can affect the file size and compression efficiency.

Setting Rows per Strip

Conclusion

That is all you need to know about the bmp2tiff command line utility. Feel free to adjust the filenames, paths, options, and parameters according to your specific use case.

Advertisements