Safari and PNG Colors

Over the last week or so, I’ve been working on the redesign for this site.  One small part of the redesign includes some rasberryNG: images to which I’ve given a specific solid background color.  These images are then placed inside some code on a page to which the exact same background color is applied via :CSS:.  So, the image should blend in perfectly with the background since they both have the same color and PNG is a lossless format, meaning that there’s no worry of pixelation or other types of degredation that might occur with, say, a JPG image used in this situation.

As I said, the image and background should match perfectly.  And they do; in FireFox and even, a bit surprisingly, in :IE:.  Where they don’t work—again, surprisingly—is in Safari.  With Safari, the background color of the PNG image and the CSS color don’t match.

It turns out, this is due to gamma correction.  Or, specifically, due to Safari trying to do gamma correction and not doing a particularly good job at it.  I found this article that gives a much, much better explanation than I ever could.  According to that article and a number of other resources I was able to find after some extensive Google searching, it doesn’t look like there’s a solution to the problem.  Well, aside from “don’t use PNG images”, that is.

The problem, though, is that I need to use PNG images.  You see, the images I’m using are being dynamically created by a script I’ll hopefully be releasing soon.  It creates images in the PNG format because 1) the GIF format is still under patent protection in some parts of the world and PHP support for it is thus a bit spotty and 2) JPG images wouldn’t work because of the previously-mentioned pixelation/degredation issues.

So, it looks like you Safari users will just have to live with images that don’t match the rest of the background color because your browser is broken in this regard.  Don’t worry, at least you’re better off than Opera users, since that browser is currently choking even worse due to the XHTML-compliant way I’m passing values in a URL (i.e. using “filen.php?var1=val1&var2=val2” instead of “filen.php?var1=val1&var2=val2").  Go figure that it would choke on the correct way and work with the invalid way. [shrug]

This is an older entry and as such, it may be by a guest author or contain formatting problems / extraneous code. If you notice something wrong with the entry, please use the Contact page to let me know the entry title and issue.

Comments

thanks for this useful bit of web dev knowledge Chris. I’ve filed it away.

Anychance we get a sneak peak of the redesign?

Two points:
1) Opera has worked just fine with correctly escaped ampersand entities since 1995! I have hundreds of web pages using them.
2) Escaping & as & is nothing new in xHTML - it goes all the way back to HTML2.0

Well, Opera may usually support them fine (in fact I’d expect it does), but in this particular instance it didn’t.  It choked.  Hard.  It was definitely the ampersand vs. character entity, too, since the issue immediately disappeared when I tried the code without the entity.

[shrug]

Leave Your Comment

Comments may be edited for content or deleted at any time. Civilized discussion is welcome. Anyone spamming, going way off topic, or otherwise being a jerk will probably be deleted or banned.

User Information

pMcode is allowed for comment formatting. pop-up mini reference

Personalization Options

Comment Security