python 3

CONVERT one or more TIF Files into a PDF:

1. Keep all TIF Files in one Folder
2. save following script as “” file
3. from command promt, go to the folder
4. python .

import img2pdf, sys, os, time

if len(sys.argv) > 1:
image_directory = sys.argv[1]
print (“I’m looking for TIFs in “, image_directory)
print (“Please tell me the directory to look in”)

image_files = []

for root, dirs, files in os.walk(image_directory):
for file in files:
if file.endswith(“.tif”) or file.endswith(“.TIF”):
print (“Discovered this TIF: “, os.path.join(root, file))
image_files.append(os.path.join(root, file))

if image_files:
output_file = time.strftime(“%Y%m%d-%H%M%S”) + “.pdf”
print (“Putting all TIFs into “, output_file)
pdf_bytes = img2pdf.convert(image_files)
file = open(output_file,”wb”)
print (“Couldn’t find any TIFs”)