Unknown resolution = 72dpi?

ImageMagickObject is a Windows COM+ interface to ImageMagick. COM+, Visual Basic, and Delphi users should post to this discussion group.
Post Reply
majime.koala
Posts: 1
Joined: 2015-07-29T10:15:36-07:00
Authentication code: 1151

Unknown resolution = 72dpi?

Post by majime.koala »

The issue:
If no resolution value is set for a graphic, "identify -format %x" returns a default value of 72dpi. This is true for both command line and VBA. However, Windows (at least my machine) returns 96dpi.
(FYI, I'm running ImageMagick 6.9.1-9 Q16 x86 2015-07-18 on 64-bit Win7 with 32-bit Office 2010.)

The question:
Is this expected behavior? It seems like IM should return null or 0 or "none" or...something.

The workaround:
For these problem graphics, "identify -format %U" returns "Undefined", so I can use that as a test.

The painful details:
I have created a VBA macro to display a list of graphics and their properties. The ultimate goal is to have end users specify a desired print width in PDF, and then have IM adjust the resolution accordingly. (Unfortunately, I'm working with an old set of tools that don't know how to read "width=5in" in XML.)

The relevant code is:

Code: Select all

                        
With Cells(rCurrent, cInfoStart + 2)
	.Value = Round(img.Identify(, "-format", "%x", "-units", "PixelsPerInch", inputDir & f.Name))
	.NumberFormat = "0 ""dpi"""
End With
Everything seemed fine, until I got to a set of PNG files for which IM tells me the resolution is 72dpi. However, both Windows Explorer and SnagIt say 96dpi. After poking though -verbose output for various files, I found the issue described above.

-verbose output for a file that has resolution defined:

Code: Select all

Image: abc.png
  Format: PNG (Portable Network Graphics)
  Mime type: image/png
  Class: DirectClass
  Geometry: 693x660+0+0
  Resolution: 48.03x48.03
  Print size: 14.4285x13.7414
  Units: PixelsPerCentimeter
...
-verbose output for a file that does not have resolution defined (note the lack of "Resolution" and the value for "Units"):

Code: Select all

Image: arrow.png
  Format: PNG (Portable Network Graphics)
  Mime type: image/png
  Class: DirectClass
  Geometry: 40x18+0+0
  Units: Undefined
 ...
Post Reply