How to convert TIFF files to PDF format on Linux
TIFF (Tagged Image File Format) is a popular image file format. Unlike other types of image files, a single TIFF file can contain multiple images (e.g., multi-page document scan) in it. TIFF editor software such as GIMP is able to support such multi-page TIFF files. If you would like to convert a TIFF file to PDF format on Linux, you can follow the instructions below.
A simple command-line approach to convert a TIFF image to a PDF document is to use a command-line utility called tiff2pdf
.
Install tiff2pdf
on Linux
To install tiff2pdf
on Debian or Ubuntu:
$ sudo apt-get install ghostscript libtiff-tools
To install tiff2pdf
on CentOS, RHEL
$ sudo yum install ghostscript libtiff
To install tiff2pdf
on Fedora:
$ sudo yum install ghostscript libtiff-tools
Convert a TIFF Image to PDF Format with tiff2pdf
OPTIONS
-o output-file
Set the output to go to file output-file
-j Compress with JPEG (requires libjpeg configured with libtiff).
-z Compress with Zip/Deflate (requires zlib configured with libtiff).
-q quality Set the compression quality, 1-100 for JPEG.
-n Do not allow data to be converted without uncompressing, no compressed data passthrough.
-b Set PDF «Interpolate» user preference.
-d Do not compress (decompress).
-i Invert colors.
-p paper-size Set paper size, eg «letter», «legal», «A4».
-u[i|m] Set distance unit, i for inch, m for centimeter.
-w width Set width in units.
-l length Set length in units.
-x xres Set x/width resolution default.
-y yres Set y/length resolution default.
-r[d|o] Set d for resolution default for images without resolution, o for resolution override for all images.
-f Set PDF «Fit Window» user preference.
-e YYYYMMDDHHMMSS
Set document information date, overrides image or current date/time default, YYYYMMDDHHMMSS.
-c creator Set document information creator, overrides image software default.
-a author Set document information author, overrides image artist default
-t title Set document information title, overrides image document name default
-s subject Set document information subject, overrides image image description default
-k keywords Set document information keywords.
-h List usage reminder to stderr and exit.
If you have installed tiff2pdf
, you can convert a TIFF image to a PDF file as follows.
$ tiff2pdf -o output.pdf input.tiff -j -q 80 -z
If you would like to extract specific pages from a TIFF image and convert them into a PDF file, what you can do is to convert the whole TIFF file into a PDF using the above method, and then edit the PDF file to your needs.
Benefits of PDF Optimization in Linux
Optimizing PDF files has several benefits, including:
- less storage space, enabling efficient data management
- faster and more reliable file transfers
- being easier to open and view on low-resource devices
- faster upload and download times
- lower storage costs, decreased network bandwidth usage, and potentially reduced cloud storage subscription fees
Linux supports the ghostscript, qpdf, and exiftool tools for optimizing PDF files.
Using ghostscript
ghostscript provides various options to optimize PDF file sizes. Let’s take a closer look.
1. Installation
Before installing tools in Linux, we use sudo apt update to update our system.
On Debian-based distributions, we install ghostscript using:
$ sudo apt install ghostscript poppler-utils
On Fedora/CentOS-based distributions, we run:
$ sudo dnf install ghostscript poppler-utils
2. Optimization
To optimize a PDF using ghostscript, we use the gs command:
gs [switches][input]
Here’s a breakdown of the different components of its syntax:
- [switches] are optional command-line options that modify the behavior of ghostscript. These options are preceded by a hyphen.
- [input] is the path to the input file(s) we want to optimize.
Let’s check out some switches in an example:
$ gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
Let’s break down what each of these switches means:
- -sDEVICE=pdfwrite specifies the output device to be used. In this case, pdfwrite indicates that the output will be in PDF format
- -dCompatibilityLevel sets the compatibility level for the optimized PDF. In the example, the compatibility level is set to 1.4, which corresponds to the PDF version 1.4
-dPDFSETTINGS=
configuration Presets the «distiller parameters» to one of four predefined settings:/screen
selects low-resolution output similar to the Acrobat Distiller (up to version X) «Screen Optimized» setting;/ebook
selects medium-resolution output similar to the Acrobat Distiller (up to version X) «eBook» setting;/printer
selects output similar to the Acrobat Distiller «Print Optimized» (up to version X) setting;/prepress
selects output similar to Acrobat Distiller «Prepress Optimized» (up to version X) setting;/default
selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file.- -dNOPAUSE prevents ghostscript from pausing between pages
- -dQUIET suppresses informational messages
- -dBATCH prevents ghostscript from exiting after processing the input file
- -sOutputFile=output.pdf specifies the output file name