Density (PPI) problems

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
Posts: 25
Joined: 2007-02-22T21:11:40-07:00

Density (PPI) problems

Post by redna379 » 2010-07-08T15:38:04-07:00

It's just that easy.
I do have a png input file (file.png), which is a 720 PPI one.
If i try these simple commands:

convert file.png file2.png
convert file.png -units PixelsPerInch -density 720 file2.png

By opening file2.png in Photoshop, it reports the resolution of the file is 719,988 pixels/inch.
Why does this happen?

The question is now posted in very simple terms, but the main reason is i'm working on a small tool to create interlaced files for lenticular printing, and to do so i'd need a very precise control against the resolution only, without resampling the image.
On the test i'm making, for example, i'd need to final file to be a 754.8 PPI. But step after step, the PPI i can see in photoshop is everytime more different than the value i set via the density option.

IM version i'm using is 6.6.3-Q16 on win7-64 (version: Portable Win32 static at 16 bits-per-pixel).

Any idea?

Posts: 1016
Joined: 2005-03-21T21:16:57-07:00

Re: Density (PPI) problems

Post by el_supremo » 2010-07-08T16:37:58-07:00

The problem is that the PNG format only allows the resolution to be specified in pixels per metre which when converted from ppi to ppm and back to ppi again has a problem with round-off error.
IM converts 720 pixels per inch to 720/.0254 = 28346ppm and stores this in the PNG. When Photoshop converts this back it gets 28346*.0254 = 719.9884ppi.

Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.

Posts: 25
Joined: 2007-02-22T21:11:40-07:00

Re: Density (PPI) problems

Post by redna379 » 2010-07-09T02:25:17-07:00

Interesting reply: i completely forgot the entire ppm issue.
Well, then i will try to go back to tiff, or some other format.


Post Reply

Who is online

Users browsing this forum: maqe, Yahoo [Bot] and 20 guests