[libpng versions: libpng16.so.16.20.0 + libpng12.so.0.54.0 ] - Linux Mint 18.3 Sylvia
Hello,
when converting a PNG file utilizing the scale or resize parameter to a new PNG file, the final PNG file lacks the Y Resolution EXIF (IFD0) tag. Instead, Pixels per unit X and Pixels per unit Y appear as new additional tag definitions. See the following minimal test case log:
Code: Select all
# 0: Check file.png (source file): X Resolution is defined, Y Resolution is defined.
exiftool -xresolution -yresolution -pixelsperunitx -pixelsperunity file.png
X Resolution : 300 # X Resolution is defined
Y Resolution : 300 # Y Resolution is defined
? # Pixels Per Unit X - UNDEFINED!
? # Pixels Per Unit Y - UNDEFINED!
# 1: Create new scaled (or resized) JPEG from source file:
convert file.png -scale 3000x3000 -quality 100 filenew.jpg
exiftool -xresolution -yresolution file.png
X Resolution : 300 # X Resolution is defined
Y Resolution : 300 # Y Resolution is defined
? # Pixels Per Unit X - UNDEFINED!
? # Pixels Per Unit Y - UNDEFINED!
# 2: Create new scaled (or resized) PNG from source file:
convert file.png -scale 3000x3000 -quality 100 filenew.png
X Resolution : 300 # X Resolution still defined!
# Y Resolution UNDEFIND / MISSING
Pixels Per Unit X : 11811 # Pixels Per Unit X - NOW DEFINED!
Pixels Per Unit Y : 11811 # Pixels Per Unit Y - NOW DEFINED!
I believe, the distorion happens because of the "new" definition of Pixels Per Unit X and Pixels Per Unit Y in the resulting PNG file. Possibly, these new values are calculate somehow with X Resolution and Y Resolution. As the latter is not defined, the display algorithms may use X Resolution and Pixels Per Unit X to calculate the width of the image to be displayed. Then, the same calculation happens for the Y axis (image height) and - due to the lack of Y Resolution - a default value for the missing Y Resolution is probably used to calculate the display height, possibly the common 72.
Example calculation (just a wild guess):
11811 PixelsPerUnitX / 300 XResolution = 39,37
11811 PixelsPerUnitY / 72 (common "default" resolution) = 164,04
So, if the X and the Y resolution differ severely after this calculation, the image will become severly distorted in either direction, also.
Help me: If someone knows of a workaround, meanwhile, I would be grateful to get to know it.
TIA and regards,
too
# Note: I use imagick in text terminals (BASH shell) on up-to-date Linux systems only.