Does convert from imagemagick misinterpret the resolution- or density-related metadata of PNG?
0
votes
2
answers
61
views
Let's grab a DIN A4 paper sheet in PNG format from https://www.a4-size.com/download/335/?tmstv=1739899566 . After unpacking the obtained archive, we get a4-size-portrait-pixels-600dpi.png. Let's inspect its meta data:
$ exiftool a4-size-portrait-pixels-600dpi.png
ExifTool Version Number : 12.57
File Name : a4-size-portrait-pixels-600dpi.png
Directory : .
File Size : 5.2 kB
File Modification Date/Time : 2020:08:28 10:46:09+02:00
File Access Date/Time : 2025:02:18 18:47:15+01:00
File Inode Change Date/Time : 2025:02:18 18:43:03+01:00
File Permissions : -rw-r--r--
File Type : PNG
File Type Extension : png
MIME Type : image/png
Image Width : 4961
Image Height : 7016
Bit Depth : 1
Color Type : Palette
Compression : Deflate/Inflate
Filter : Adaptive
Interlace : Noninterlaced
Palette : 255 255 255
Image Size : 4961x7016
Megapixels : 34.8
As we see, the resolution/density tags are missing. So let's add them, using https://unix.stackexchange.com/a/791125 :
$ dpi=600 && exiftool -o a4-size-portrait-pixels-600dpi.exiftool.png -XResolution=$dpi -YResolution=$dpi -ResolutionUnit=inches -PixelsPerUnitX=$(( dpi * 10000 / 254 )) -PixelsPerUnitY="$(( dpi * 10000 / 254 ))" -PixelUnits=meters a4-size-portrait-pixels-600dpi.png
1 image files created
But now:
$ convert a4-size-portrait-pixels-600dpi.exiftool.png -density 600 a4-size-portrait-pixels-600dpi.exiftool.convert.pdf
$ pdfinfo a4-size-portrait-pixels-600dpi.exiftool.convert.pdf
Title: a4-size-portrait-pixels-600dpi.exiftool.convert
Producer: https://imagemagick.org
CreationDate: Tue Feb 18 18:55:03 2025 CET
ModDate: Tue Feb 18 18:55:03 2025 CET
Custom Metadata: no
Metadata Stream: no
Tagged: no
UserProperties: no
Suspects: no
Form: none
JavaScript: no
Pages: 1
Encrypted: no
Page size: 234.378 x 331.465 pts
Page rot: 0
File size: 35775 bytes
Optimized: no
PDF version: 1.3
As we see, the page size is wrong. In Postscript points, the right size would have been 595 × 842 pts.
What's going on here? Are we overusing exiftool+convert, or is convert simply wrong?
We might suspect that we shouldn't need to tell the toolchain the density/resolution more than once. However, (in the ideal world) you should be able to say as often as you wish how big your pixel or your dot is (in our case, 1/600 of an inch wide and 1/600 of an inch high) to any tool in the toolchain.
Asked by AlMa1r
(1 rep)
Feb 18, 2025, 06:00 PM
Last activity: Feb 24, 2025, 08:59 PM
Last activity: Feb 24, 2025, 08:59 PM