identify reports 299.999dpi while it is 300dpi

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
leyn
Posts: 8
Joined: 2011-11-09T02:45:30-07:00
Authentication code: 8675308

identify reports 299.999dpi while it is 300dpi

Post by leyn »

Hello,

I have a Canon Lide scanner which I'm using
to save to color .png files. I set the resolution to
300dpi in both directions.

For some reason, I have to be able to ask up the resolution
after scanning. I do this with 2 programs:

1) IrfanView, info button: IrfanView correctly reports the 300dpi
in both directions.
2) identify -units PixelsPerInch -verbose filename.png
Here I get a resolution in both directions of
299.999dpi.

The idenfy behavior is very anoying: I need integers and not floats
in order to calculate some other parameters.

Why is identify reporting with a float, and can something
be done about this?

Best regards,

Francky Leyn
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: identify reports 299.999dpi while it is 300dpi

Post by glennrp »

The reason is that PNG stores the resolution in pixels/meter which can't
exactly represent dpi. Identify is simply reporting what it has.
Post Reply