Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Pillow to find DPI

I'm trying to find out the DPI of an image using the Pillow module.

I'm doing this

image = Image.open("image.jpeg")
print(image.info["dpi"])

which returns

(300, 300)

Why is this a tuple? I was expecting a single value. What do the two values relate to and which should I use to give me the same value I see in photoshop?

like image 969
Dunc Avatar asked Oct 17 '22 07:10

Dunc


1 Answers

The docs do not say much about this, but I've gone roughly through source code and it seems that this refers to DPI in x and y axis (look at search results)

Especially this suggests that there could exist something as non-square pixels.

like image 75
gonczor Avatar answered Nov 15 '22 05:11

gonczor