3
from PIL import Image

im = Image.open('whatever.png')
width, height = im.size

In the above code what are the dimensions of width and height? I mean are they in mm,inches or something else?

If I refer a pixel by coordinates (x,y) then what will be the distance of that pixel from 0,0 or top left corner in any physical unit like mm, inches etc?

dushyant7917
  • 574
  • 7
  • 9

1 Answers1

6

Your tuple comes back as a measurement in pixels

To address the second part of your question, it depends on your display device. If you know the physical size of the device and the resolution, you can figure out how many pixels per physical unit and extrapolate that out from the point of origin on your image.

  • Suppose the tuple gives (W,H) ... Then that means the image has W*H pixels right? But what is the dimension of each pixel.. How do I get the distance of a pixel[x,y] from 0,0 – dushyant7917 Mar 21 '19 at 18:20
  • it's all really dependant on your definition of distance, if it's a physical measurement you're after you need to consider the geometry of the display device you're rendering the pixel on – Matthew Martin Mar 21 '19 at 18:29
  • Generally 1inch = 96 pixels – Charanjit Singh Sep 09 '20 at 13:04