ImageMagick version
6.9.11-60
Operating system
Linux
Operating system, version and so on
Ubuntu 22.04.4 LTS
Description
Imagemagick provides identify -ping to perform quickly obtaining input image dimensions:
$ identify -ping -format '%w %h\n' pdfs/x.pdf
612 828
612 828
$ identify pdfs/x.pdf
x.pdf[0] PDF 612x828 612x828+0+0 16-bit sRGB 2707B 0.000u 0:00.000
x.pdf[1] PDF 612x828 612x828+0+0 16-bit sRGB 2538B 0.000u 0:00.000
However, these dimensions are slightly scaled compared to the /MediaBox of the PDF:
$ identify -verbose pdfs/x.pdf | grep 'Page geometry:'
Page geometry: 596x842+0+0
Page geometry: 596x842+0+0
$ pdfinfo pdfs/x.pdf | grep 'Page.*s'
Pages: 2
Page size: 596 x 842 pts (A4)
Ideally identify would reliably return the actual image (PDF page /MediaBox) dimensions.
PS. One reference was found to trying pdf:HiResBoundingBox, but it's unclear if this is correct or should work:
$ identify -format '%[pdf:HiResBoundingBox]' pdfs/x.pdf
identify-im6.q16: unknown image property "%[pdf:HiResBoundingBox]" @ warning/property.c/InterpretImageProperties/4051.
Steps to Reproduce
$ identify -ping -format '%w %h\n' pdfs/x.pdf
612 828
confirm this output differs, and appears to be slightly higher than:
$ pdfinfo pdfs/x.pdf | awk '/pts/{print $3,$5}'
596 842