potential bug setting density and units in PNG IM 6.5.4.0

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

potential bug setting density and units in PNG IM 6.5.4.0

Post by fmw42 »

IM 6.5.4.0 Q16 Mac OSX Tiger

Create test image:
convert rose: rose.png
identify -verbose rose.png
Image: rose.png
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 70x46+0+0
Resolution: 72x72
Print size: 0.972222x0.638889
Units: Undefined


Now change the density and units:
convert rose.png -density 300x300 -units pixelsperinch rose2.png
identify -verbose rose2.png
Image: rose2.png
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 70x46+0+0
Resolution: 118.11x118.11
Print size: 0.592668x0.389467
Units: PixelsPerCentimeter
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: potential bug setting density and units in PNG IM 6.5.4.0

Post by magick »

Apparently the PNG specification only permits pixels per centimeter and does not support pixels per inch.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: potential bug setting density and units in PNG IM 6.5.4.0

Post by fmw42 »

magick wrote:Apparently the PNG specification only permits pixels per centimeter and does not support pixels per inch.
OK. 300 dpi / 2.54 cm/in = 118.11 dpc

P.S. Perhaps Anthony would not mind adding a comment to his page about PNG format to point this out. Thanks
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: potential bug setting density and units in PNG IM 6.5.4.0

Post by anthony »

Perhaps 'undefined' means Pixels Per Inch.

I think we should get the PNG experts view on this!


Question. If the units is currently DPC, and you change it to DPI, is the density values corrected
appropriately?

I suppose then you should use -set to ensure one setting does not change the other!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Mazin
Posts: 10
Joined: 2008-11-24T13:30:50-07:00

Re: potential bug setting density and units in PNG IM 6.5.4.0

Post by Mazin »

According to the PNG specification ( http://www.w3.org/TR/PNG/#11pHYs ), the pHYs field contains pixel dimensions on the X and Y axis along with a unit specifier. This unit specifier has two options: none, and metres. So if I understand this correctly, you can either set pixel/metre or the aspect ratio only. That is, a setting of 72 by 72 without units only says that the image has square pixels, and I would guess that the application is free to interpret this as a default 72 or whatever it wants to. No other units besides "none" and "metre" are defined.

Forgive me if I misinterpret the spec.
Post Reply