Search code examples
pythonpython-imaging-librarydimension

What is the dimension/unit of the values given by PIL image.size


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?


Solution

  • 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.