Wednesday, February 7, 2007

PNG vs. JPEG

Early this month, I was working on a problem of a software's visual incompetence under extreme lighting condition. The solution was simple: put in a set of predefined styles in CSS format and create a switch in the front-end interface that enables mix or selection of these templates to create desired effect accordingly.

Everything worked fine except all my toolbar control images (GIF) failed transparency. That forced me to search for another image file type for replacement. I found PNG (Portable Network Graphics) -- the free, extensible file with lossless compression and alpha transparency.

There are 4 noticeable features over the old GIF: better compression, alpha channel transparency, cross-platform brightness, progressive display. The only thing PNG does not support is animation. What about JPEG you asked? JPEG is better used on transmission of finished true-color images; And TIFF on black-and-white illustrated graphics. But wait. IE does not support alpha transparency. Until there's better, more standardized solution to this, the trick is to write a JavaScript object to display PNG using the AlphaImageLoader filter. See the detail explanation provided by Michael Lovitt here.

Other readings:
1. Struts/MVC at Apache
2. AJAX by Jesse James Garrett
3. What should I use for my next project

No comments: