This isn't a problem but rather trying to improve my understanding of how DPI is stored in various file formats and discussion as to why it works the way it does.
I am doing a lot of work with images (JPG's, PNG's and Tiff) and detecting their resolution.
For example I can run this on an image in Imagick:
$imagick = new Imagick($filename);
$data = $imagick->identifyimage();
var_dump($data);
And it will give me the resolution and the units (PixelsPerCentimeter or PixelsPerInch)
In windows (11) I can only see Resolution in the properties for JPG, not on PNG's and regardless of whether you make the PSD as a PixelsPerCentimeter or PixelsPerInch it's displayed as (300 dpi).
In Imagick (Version: ImageMagick 6.9.11-60 Q16 x86_64) - it is able to see the difference between a JPG saved at PixelsPerCentimeter and the JPG saved as PixelsPerInch. But with PNG it gives PixelsPerCentimeter regardless of how I created/saved it in Photoshop.
Photoshop (24.1.0) also can detect the PixelsPerCentimeter on the JPG - but the PNG's all "say" they are PixelsPerInch, even if I saved them as PixelsPerCentimeter.
Now I fully understand that 118.11 PixelsPerCentimeter = 300 PixelsPerInch but I'm really interested in how why the Windows/Photoshop and Imagick treat them this way?
I did consider that it could be a side affect of creating the files in Photoshop to begin with, so I created a file using Imagick (PNG, 300dpi,PixelsPerInch) but Imagick has given it as 118 PixelsPerCentimeter.
So I guess my question is this: Are these differences down to the way the files are read or the actual meta data being stored within the file types?
This is not an authoritative, complete answer - more of a "heads-up" since nobody has answered you.
It is a bit of a minefield and different software goes to different lengths. If you want to study it further, exiftool
with its -v
options is generally most helpful.
Regarding PNG images
The original PNG specification had a pHYs
chunk that gave the horizontal and vertical resolution in metres only, inches were unavailable. The various PNG tags are described here.
Some software (ImageMagick and exiftool
) stored the (JPEG-style) APP1 data (see later) unofficially in a zTXt
chunk. Some didn't.
In July 2017, the PNG specification was updated to allow an eXIf
chunk. See here.
Regarding JPEG images
In JPEGs, the x/y resolution might be stored in an APP0, or APP1, or APP13 (Photoshop) segment. The best description of these I know is here.
I've never been that interested in XMP data, but I believe the x/y resolution might also be stored in there too/instead.