Gamma Correction and Color Correction - PNG is still too hard
If you're not reading this post in a feed aggregator you can tell that Alexander and I collaborated on a new design over the weekend. (Yes, he was paid.)
By "collaborated" I mean that Alexander is awesome and I learned a bunch of obscure browser-specific nonsense that I didn't know before. I thought that at least some of these problems were fixed by 2007. Oy, what a mess.
I was looking forward to using PNG on this site, and it's the One True Format, right? You'd thing it'd be a no-brainer.
We put that brown background in the header in a div, as a background-image.
<style type="text/css">
#header1 {
height: 79px;
background: url(header-background2-gamma.png) scroll no-repeat;
background-color: #5C4837;
background-position: right 50%;
}
</style>
The original design was fixed in width, so we made it fluid and stretchy. Because the header is a fixed weight, I wanted it to be right-aligned. It's aligned via background-position to the right.
In order to make it stretchy, I made the background color match the left edge of the graphic. This technique worked great in FireFox, but looked lousy in IE6 or IE7. You can see a rendition below or visit a sample page. If you're running IE, you'll see a graphic like the one seen below. If you're running Firefox, you'll see two identical bands.
Nutshell - PNGs look darker on IE than anywhere else. Even IE7 Release!
What different is that, as you probably know, IE doesn't seem support the Gamma Correction data that is added by most PNG-producing applications. Or, it supports it too well! :)
Not only is there crappy PNG support out there, as most don't completely implement other very interesting parts of the spec, like Color Correction, but the spec itself was apparently ambiguous for a number of years.
I went around and collected this bunch of links...
- The Sad Story of PNG Gamma "Correction"
- PNG Home Page
- TweakPNG - Low-Level PNG modifier
- SitePoint on PNG Colors in IE
- A 2005 Blog Post by Sam Fortiner, the IE Dev who wrote Transparent PNG Support in IE7
- Free Virtual PC Image with IE6 - for testing purposes.
- IE PNG Fix (as an HTC/IE Behavior)
- PNGGauntlet - A .NET Program that fronts Ken Silverman's PNGOut
- You'll definitely want these. I run it in a loop in PowerShell:
dir *.png | foreach-object { pngout $_ } - The 2003 Joint PNG Spec
- Problems with 8-bit PNGs in IE
The real frustration for me here, is why should I still care about this stuff? It should be WAY easier...I wonder when the larger problem of color on the web will be solved. I'm really frustrated and a little shocked that I'm still having to sweat this kind of detail these days.
Big thanks to Jon Galloway for helping me figure this out and remove the Gamma Correction from my PNG.
About Scott
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
About Newsletter
max- Site load time seemed about the same to me. [shrug]
I'll look at some additional speedups I can make...
http://www.csc.calpoly.edu/~bfriesen/software/dropper.shtml
In my case, I was positioning a small solid-color .png file, RGB (180, 17, 26), which I created with Paint .NET, next to a div element of the same background color on a web page. Firefox correctly rendered the .png image as (180, 17, 26) so the division between the .png file and the div element was seamless; but IE7 rendered the .png as (172, 12, 20) (as shown by the Dropper utility) -- close, but not exactly the same as the original color. There was a noticeable difference between the color of the image and the color of the div element.
After spending a few minutes doing research on the issues with gamma correction and .png files, for the sake of expediency I just took the easy way out, and just re-saved the .png file as a .gif. IE7 did render the .gif properly on the web page.
I'll do a Page Weight analysis, before and after.
* Every image has gone through PNGOUT
* All JavaScript has been minimized
* All JavaScript and CSS is currently cached for a week
If the site feels slow, it is one of these things...(assuming you have a fast pipe)
* This is the first time you've visited the site in a while
* You have a slow computer (javascript is slow for you?)
* I've completely missed something obvious
Nice new design though :)
* nice redesign (and I did not notice any speed differences)
* script defer is not supported in Gecko based browser [1]
* The comments name boxes remember functionality has an issue with umlauts, e.g. my 'ö' is restored as 'ö' on reload (yay l10n/i18n support in 2007; I should better reported this to dasBlogs, though)
* Pet peeve: It is Firefox, not FireFox [2]
[1] https://bugzilla.mozilla.org/show_bug.cgi?id=28293
[2] http://www.mozilla.com/en-US/firefox/
I definitely like the look of the comments for sure. The rest is still a little blocky but I think that's my personal taste - the Google ads crashing over top of some of the side is a bit wacky.
Otherwise nice!
Which kinda sucks.
A couple of notes:
The Google ads block is too wide. It's overflowing to the right nav bar and blocking anything under it.
If you paid someone to do the design for you, do you need to mention that the design was used with his permission?
Forgot the mention that I am using FF 2.0. In my IE 6.0, the right nav bar starts after the end of the content.
( IE is blocking Google ads)
I can't really think it's related to the redesign, that's just when it appeared to start happening.
Comments are closed.