I found out that the behaviour of PIL was totally correct and simply Photoshop "adds" some more information sometimes when a JPEG file is opened.
I summarize what I discovered here, hoping it might be useful to others. The JPEG standard doesn't cover a way to encode the resolution of a file but the JFIF extension does. For a quick and useful introduction to these concepts you can visit the Wikipedia page http://en.wikipedia.org/wiki/JFIF Here you can find a very useful table with the byte map of a JFIF file. In particular the "Density Units" field is a byte with three possible values: * 0 - No units, aspect ratio only specified * 1 - Pixels per Inch * 2 - Pixels per Centimetre With a value of Density Units == 1 or == 2 you can get the resolution information in the next two fields (2 bytes long each), that is "X Density" and "Y Density". Of course these map exactly "dpi" when Density Units == 1. For all the images that I opened with PIL and couldn't find the dpi attribute I "hex-dumped" them and found out the following values for these fields: * Density Unit: 0 * X Density: 1 * Y Density: 1 I assume that in these cases Photoshop simply sets the resolution to the default for screens (which is 72 dpi at least on the Mac). Correctly PIL doesn't set the dpi attribute in the "info" dictionary. To cut this long story short... I was wrong and PIL rocks hard! :-) Hope my experience could help others. Ciao, Luca Luca De Santis Pisa, Italy On 9/17/07, Luca De Santis <[EMAIL PROTECTED]> wrote: > That's exactly the same problem I incurred into. > I tried PIL version 1.1.6 on a Mac OS X 10.4 and on an old Linux box > and can't get the DPI attribute for JPEG and PNG files that I've > created with Photoshop. > > I tested that both on Python 2.5 and Python 2.1.3 with the same result. > > I tried also to update libjpeg on Linux but nothing changes. > > Any help on that is greatly appreciated. > TIA. _______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig