Page 1 of 1

possible bug creating pdf -- units do not show

Posted: 2018-08-07T10:02:11-07:00
by fmw42
IM 6.9.10.9 and IM 7.0.8.9 Q16 Mac OSX.

I tried converting the logo: image to pdf and specified the units, but they do not show when listed with identify -verbose

magick logo: -units pixelsperinch logo.pdf

im7 magick identify -verbose logo.pdf
Image: logo.pdf
Format: PDF (Portable Document Format)
Mime type: application/pdf
Class: DirectClass
Geometry: 640x480+0+0
Resolution: 72x72
Print size: 8.88889x6.66667
Units: Undefined
Colorspace: sRGB
Type: PaletteAlpha
Base type: Undefined
Endianess: Undefined
Depth: 16/8-bit

Re: possible bug creating pdf -- units do not show

Posted: 2018-08-07T11:48:17-07:00
by snibgo
"-density" and "-units" apply to the raster image that will be embedded in the PDF. They don't apply to the PDF as a whole.

Re: possible bug creating pdf -- units do not show

Posted: 2018-08-07T15:22:21-07:00
by fmw42
The issue I am trying to resolve is how to get the print size from the verbose information for a scanned PDF (or other vector formats). I have scanned a document to PDF format and when I look at the verbose information it shows the print size as numerical values and the density, but never shows the units. So how am I supposed to interpret the density and print size? Is it always fair to assume pixels-grinch and inches?

For example from the scanned PDF:

Resolution: 72x72
Print size: 8.45833x10.9861
Units: Undefined

Here is an SVG example that has the same issue:

Image: wizard.svg
Format: SVG (Scalable Vector Graphics)
Mime type: image/svg+xml
Class: DirectClass
Geometry: 940x1250+0+0
Resolution: 72x72
Print size: 13.0556x17.3611
Units: Undefined

Re: possible bug creating pdf -- units do not show

Posted: 2018-08-07T17:53:42-07:00
by snibgo
"identify" shows metadata that Ghostscript has written, and this in turn depends on what "-density" and "-units" we give IM before reading the PDF. The default is "-density 72" with no units. But we can override:

Code: Select all

magick -density 123 -units pixelsperinch abc.pdf -verbose info:
Yes, when GS returns no units, I think we can assume pixelsperinch.

SVG is similar, but the SVG file may specify density and units internally (but it may not).