Convert TIFF To PDF In Python
Last updated January 31, 2024 by Jarvis Silva
In this tutorial we will see how to convert tiff to pdf in python, TIFF (Tagged Image File Format) it is used to store raster graphics and images, The key feature about this file format is the ability to handle wide variety of image types.
Install Pillow Library In Python
To do TIFF to PDF conversion using python I will use the pillow library which allows us to convert images to different formats, It will allow us to convert tiff file to pdf with just 4 lines of python code and you can also use it to convert other formats.
pip install Pillow
Copy and paste the above command in your terminal it will install the library in your system.
Python Code To Convert TIFF To PDF File
from PIL import Image
with Image.open("test.tiff") as img:
# Converts the tiff to rgb
img = img.convert("RGB")
In the code we first import the Image module from the pillow library, The second line opens the tiff file using the image module from pillow, As you can see it converts tiff file to RGB before saving it to a pdf file it is necessary because it cannot save mode RGBA.
After you run the program you will see it creates a pdf file in your folder.
Here are some more python tutorials you might like:
- Convert base64 to zip file in python.
- Convert zip file to base64 in python.
- Convert image to base64 in python.
I hope you found this tutorial helpful and useful do share it with someone who might need it. Want to stay updated with our latest tutorials then join our telegram channel.
Thanks for reading, Have a nice day 🙂