Resolution info is optional in JPEG files (it's a part of the JFIF
standard, not JPEG itself) and even if present, it may not be
expressed in dots per inch. PIL only sets the "dpi" field if the
information is there, leaving it to your code to provide a suitable
default value (or behaviour) for you
I find that the info object often does not have the exact key you are
looking for, many different encoders use slightly different variants, or
don't include it at all. My best advice is to print out the info for several
of your files and look for patterns. Also there are some tools for working
more
I am trying to determine DPI from images. Can anyone help?
I tried:
img = Image.open("Hamerkop.jpg")
img.info["dpi"]
but it doesn't work for all jpegs.
Python 2.5.1
PIL 1.1.7
Regards,
Sam
___
Image-SIG maillist - Image-SIG@python.
It seems to me that the dpi read/write support in TiffImagePlugin.py
is broken. When reading an image it will set the dpi in the info
dictionary only if RESOLUTION_UNIT == 1. Similarly it will set
RESOLUTION_UNIT to 1when saving an image as a TIFF with dpi values
given.
But according to th