Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get image dpi for tif files using Pillow

Tags:

python

pillow

How to get tiff image DPI using pillow? Cant see in documentation.

from PIL import Image
im = Image.open('test.tif')
print("im dpi?")
like image 326
user3654650 Avatar asked Jun 05 '14 01:06

user3654650


People also ask

How do I know the DPI of my TIFF?

To find out an image's DPI in Windows, right-click on the file name and select Properties > Details. You'll see the DPI in the Image section, labeled Horizontal Resolution and Vertical Resolution. On a Mac, you need to open the image in Preview and select Tools > Adjust Size. It's labeled Resolution.

Does Pillow support TIFF?

Pillow builds on this, adding more features and support for Python 3. It supports a range of image file formats such as PNG, JPEG, PPM, GIF, TIFF, and BMP.

How do I check an images DPI?

Right-click on the image file and click Properties at the bottom of the menu. In the Properties menu, click the Details tab. Scroll down to the Image section of the menu, you'll see two values that give you your image's DPI: Horizontal Resolution and Vertical Resolution.


1 Answers

Image resolution in DPI should be available in info dictionary (more about info for tiff images can be found here):

print(im.info['dpi'])

Though, not all images provide this information.

like image 154
Marcin Avatar answered Oct 19 '22 23:10

Marcin