I know that there can be sometimes a problem when there are different density values in different profiles. Well, one could say, that's the fault of such input files.
But I have an example where the same density value is stored in the profiles - and there can be still a problem in ImageMagick with that value.
Take that image:
rose.tif
That file has a normal EXIF profile - and I also inserted a Photoshop (8BIM) profile. Both profiles have the same values for the horizontal density, the vertical density and the unit - I used 300x300 PixelsPerInch in this example. There are no other values in that file!
At this point, ImageMagick still displays the correct values of course:
Code: Select all
identify -verbose rose.tif
Units: PixelsPerInch
Code: Select all
identify -format "%x x %y" rose.tif
Now conversion #1 to PNG:
Code: Select all
convert rose.tif rose1.png
identify -verbose rose1.png
Units: PixelsPerCentimeter
Code: Select all
identify -format "%x x %y" rose1.png
And after a second PNG conversion:
Code: Select all
convert rose1.png rose2.png
identify -verbose rose2.png
Units: PixelsPerCentimeter
Code: Select all
identify -format "%x x %y" rose2.png
So, one gets 300 PixelsPerCentimeter (762dpi) instead of 118.11 PixelsPerCentimeter (300dpi).
I was using IM v6.6.4-2 Q16, on Windows XP.
More details:
I think, when reading the TIF file, ImageMagick takes the horizontal and vertical density from the Photoshop profile and the unit from the EXIF profile. Then, for the conversion to PNG, IM has to convert the value from inches to centimeters and automatically stores 11811 pixels per meter in the pHYs chunk in this example. So far, there's no problem (as all original values in the TIFF are ok). But IM also stores the Photoshop profile as compressed text chunk (with the original 300 PixelsPerInch!). When reading from that PNG, IM takes the unit from the pHYs PNG chunk - but takes the horizontal and vertical density from this Photoshop profile in PNG! In the first PNG conversion, the file is still ok (IM only displays the wrong value). But in the second PNG conversion, IM writes this wrong value also into the pHYs chunk...
Additionally, I'm also wondering why 'identify -verbose' and 'identify -format "%x %y"' display different values. 'identify -verbose' can take the values from various places (as described before) - but 'identify -format' seems to take the values just from the pHYs chunk here.
I think: The behaviour that takes the elements for the density (the horizontal density, the vertical density and the units value) from different places can be problematic. (Especially in PNG files - as the normal pHYs chunk can't store the values as PixelsPerInch.)
The problems would be avoided if the elements for the density were always taken from the same place. The density value could still be taken from the Photoshop profile (if there's no pHYs chunk), but then the units value should be taken from there, too.
Is this possible? (Perhaps at least for PNG files?)