Re: Strange issue with PNG files

Rainer Brockerhoff <[email protected]>
Newsgroups gmane.comp.macosx.devel
Message-ID <p06240823c7b89160635e@[192.168.1.100]>
At 12:00 -0800 06/03/10, [email protected] wrote:
>Date: Fri, 5 Mar 2010 21:53:33 +0100
>From: Markus Hitter <[email protected]>
>To: Eric Gorr <[email protected]>
>Message-ID: <A9A49D60-FA0A-4431-A6D6-5A0BAC363D3F-5aU9hSJ5JWgb1SvskN2V4Q@public.gmane.org>
>
>Am 04.03.2010 um 20:23 schrieb Eric Gorr:
>
>>> If you want to draw it pixel for pixel despite the high ppi, use -
>>> pixelsHigh/-pixelsWide, create an NSSize of that size, and draw it 
>>> "scaled".
>>
>> So, the only/recommended way to determine when an image is in this 
>> state is to compare what [image size] returns vs. pixelsHeight & 
>> pixelsWide?
>
>IIRC, the recommended way is to not care about the number of pixels 
>of an image, but to draw it by size. Resolution independent display 
>technologies aren't that far away. With these, image pixels won't 
>match display pixels even when drawn at 72 dpi (1 pixel = 1 image
>size unit).

If you're "drawing by size", be aware of a longstanding issue with the PNG format, in that resolution in the 'pHYs' chunk can only be specified in meters, meaning there's no exact equivalent for 72 dpi.
http://www.w3.org/TR/PNG/#11pHYs

I have rdar://5532687 open since 10/10/2007 (!) about this. Basically, if the 'pHYs' chunk in a PNG specifies meters, the nearest equivalent is 72.009. This can distort larger PNGs if you try to draw them as 72 dpi, or at some exact ratio. The bug relates to Preview 4.0(467) and up generating PNG files at 72.009 dpi - older versions set the 'pHYs' chunk to "unknown unit", which defaults the image to exact 72 dpi when read by Mac OS X.

Easily verified: open a .icns file in Preview, save as .png, open the file in (say) Photoshop, you'll see the dpi set to 72.009.

I've just tested this again in 10.6.2 (Preview 5.0.1). This now seems to round 72.009 down to 72, so that all appears to be well, but it's not! Preview 4.x showed 72.01.

Anyway, be sure to double-check your PNG files. I just filed this on OpenRadar: http://openradar.appspot.com/radar?id=169405
-- 
Rainer Brockerhoff  <[email protected]>
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
 In their own business even sages err."
Weblog: http://www.brockerhoff.net/bb/viewtopic.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.