linello linello -5 years ago 259
Linux Question

Getting PDF size in millimeters with image-magick on Linux

Is there some image-magick tool to get the size of a PDF file in millimeters?
I've tried with the imagemagick "identify" tool but the informations are only in pixels. How can I specify to output the information in millimeters together with the DPI?

Answer Source

Take a look at the first dozen lines of identify -verbose. It should list the following info.

  • Geometry
  • Resolution
  • Print size
  • Units

The Print size can be converted to mm easily, or found via google quickly.

For example...

identify -verbose document.pdf | head -12

Which returns

Image: /full/path/to/document.pdf
  Format: PDF (Portable Document Format)
  Mime type: application/pdf
  Class: DirectClass
  Geometry: 792x612+0+0
  Resolution: 72x72
  Print size: 11x8.5
  Units: Undefined
  Type: TrueColorAlpha
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 16/8-bit

So about 25.4 mm per inch will result in

11 * 25.4 = 279.4mm
8.5 * 25.4 = 215.9mm

Of course YMMV if the PDF is a non-traditional page-size.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download