ArticlesForumDownload AboutContact

boakes.org

nice of you to drop by. tea?

Tags: Questions, Website

IE and PNG’s

October 25th, 2005, by Rich.

IE and PNG's

How can I tell my Apache server that MSIE prefers JPEG files over PNG?

The images you see associated with each story on this website are available in two formats. The first (and preferred) format is PNG. The second format is JPEG. JPEG is still good, but doesn’t include alpha transparency information.

Content Negotiation

The two formats are used so that browsers which cannot display PNG’s are instead sent JPEG’s automatically. This works because of an Apache feature called content negotiation. The idea of content negotiation is that it enables the client to tell the server what kinds of file it can use.

The assumption of this technique is that the client knows what it can and cannot display, and that the client is correct when it gives this information to the server.

In the case of Internet Explorer version 6, this is not the case. IE6 cannot display PNG’s properly.

What I want to be able to do is to have the Apache server refuse to send PNG’s to IE as part of it’s content negotiation, thus leaving JPEG’s as the only option. Such behavior, however, has eluded me; so please speak up if you know how to achieve it.

It’s also worth mentioning that although it could quite easily be done in PHP, it would mean that the pages could no longer be cached, so this is not solution.

Alternatives

If you’re viewing this site using IE6, it probably looks bad, sorry; IE6 sucks and there’s only so much time I’m able to commit to cleaning up Microsoft’s mess.

IE7 is on the way but in the mean time you might like to try an alternative. Personally I use Firefox but Opera is also very good. Both are capable of rendering content properly.

3 Responses to “IE and PNG’s”

  1. 1
    Thomas Says:

    Are you looking for a away to do transparency in PNG files in IE? If so I can help. http://www.twistermc.com/shake/html-resources.php

  2. 2
    Rich Says:

    Hi Thomas, thanks for your suggestion.

    I tried your JavaScript based solution this morning and found that it wouldn’t work with my particular setup.

    For the record it’s the third such fix I’ve tried, the other two were Dean Edwards "IE7" and Bob Osola’s pngfix.

    The specific issue is that your javascript looks for a .png signature on the filename, however, where I have Content Negotiation setup, I don’t use filename extensions - the specific file that gets sent is specified by the server, and it appears that JavaScript only has access to the request URI rather than the response filename.

    There is an ulterior motive to using content negotiation, which is that DeerPark supports SVG natively, so I want to be able to gracefully switch to a mainly SVG embellished site without reducing the experience for users of older systems. Consequently, anything that fixes PNG’s, must be able to handle the fact that the URI’s it has to work with may not have file extensions.

  3. 3
    chris bristow Says:

    “hath png”

Leave a Reply