possible bug creating pdf -- units do not show

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

possible bug creating pdf -- units do not show

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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).
snibgo's IM pages: im.snibgo.com
Post Reply