This Python script is used to convert TIFFs in a given directory into a single multi-page PDF. It can also be run recursively, to turn the TIFF contents of every folder within a root directory into a discrete multi-page PDF. It uses the Pillow PIL fork library to load and compress TIFFs before saving them as a single PDF. Because Pillow uses JPEG compression to reduce the size of the PDF file output, the resulting PDFs may or may not be considered suitable for publishing.
The script requires Python version 3.6 or newer and an up to date version of the pillow library. To install pillow using the Windows command prompt and pip, run the following commands:
python -m pip install --upgrade pip
python -m pip install pillow
To run the script on a single directory of TIFFs, run the script as:
python tiffs_to_pdf.py <path_to_folder>
To run the script recursively on several directories, each containing TIFFs, run the following:
python tiffs_to_pdf.py <path_to_root_folder> -r
When run recursively, the script will identify any folders containing TIFF files and create a PDF one directory above the TIFFs themselves. The PDF file will be named according to the folder containing the TIFFs. If that folder is named "TIFF", "TIFFs", "Master", or "Masters", the PDF will be given the name of that folder's parent folder, in an attempt to capture the object name for the PDF. Additional "generic" folder names to be ignored can be added to the "genericTest" list on line 69.
Download the script from GitHub: