PNGs, PNGs, and more about PNGs

 

PNGs are a handy tool for web developers to use when creating websites. There are a lot of misconceptions about them, and I hope to clear the air in this article. We will define what PNGs are, how they differ from JPG and GIF, what the misconceptions are, and finally a little bit on how to get them to behave in IE6.

What are PNGs?

PNG is an image format comparable to JPG and GIF. It stands for Portable Network Graphics. PNG was originally created to eliminate GIFs and provide better compression at a higher quality.

Why not just use JPG and GIF?

Each image format is still around, and thus means they each have their own strengths and weaknesses. JPG is great for photographic images. Images with gradients and lots of colors are great for JPG. GIF on the other hand is great for logos, and images that have large areas of one color. This normally means there is not a wide range of colors and GIF

The major differences between GIF and PNG are the following:

  • GIF supports animation and PNGs do not
  • PNGs are less supported among browsers than GIFs
  • MOST of the time PNG have smaller file sizes
  • PNGs have better transparency options which include alpha transparency

Common PNG Misconceptions

The following is a skimmed down list of some of the Misconceptions out there about PNG. Don’t feel bad if you have fallen into these misconceptions as I have as well.

  • PNG is great, but I can’t use them because they don’t work in Internet Explorer.
  • PNG always has the smallest file sizes.
  • PNG is the all-around best format.

I have taken these from a great article on CSS-Tricks titled, Misconceptions about PNG, so please check it out!

IE6 PNG Transparency Fixes

This is probably the biggest reason that PNG has not taken off more than it has. Its support is limited at times and Internet Explorer chokes on them. Actually it really only chokes when transparency is involved. To our relief, there are many easy fixes out there for us to use.

I suggest you read, 5 Easy Ways to Tackle IE6’s Transparency Issues from NETTUTS for more of an in depth description of each of the following.

  • Unit PNG Fix
  • DD_BelatedPNG Fix
  • Twin Helix Fix
Quick Usage:
Unit PNG fix
<!--[if lt IE 7]>
        <script type="text/javascript" src="unitpngfix.js"></script>
< ![endif]-->
DD_BelatedPNG fix
<!--[if IE 6]>
<script type="text/javascript" src="DD_belatedPNG.js"></script>
<script type="text/javascript">
  DD_belatedPNG.fix('.png_bg');
</script>
< ![endif]-->
Twin Helix Fix
<style type="text/css">
img, div, a, input { behavior: url(/css/resources/iepngfix.htc) }
</style>

That about does it for PNGs. You are all PNGed out I am sure…

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Add to favorites
  • Design Float
  • DZone
  • email
  • FriendFeed
  • PDF
  • Propeller
  • Reddit
  • RSS
  • StumbleUpon
  • Twitter

Related posts:

  1. PNG-8 Alpha Transparency (screencast)
  2. Animate Text with jQuery Easing (screencast)
  3. Dealing with CSS Font-Sizes
  4. Tired of SIFR? Get a Facelift!


Written by Brenley Dueck

 

9 Responses to “PNGs, PNGs, and more about PNGs”

  1. O. Says:

    January 26th, 2009 at 8:39 am

    Why not explain the differences between the three fixes? I’ve had hard times dealing with PNGs in IE6 on my websites until I dropped the support for IE6. That is because I could not find a single solution that would work nice whenever I needed it to.

  2. Anthony Hastings Says:

    January 26th, 2009 at 10:09 am

    Great article, short and to the point. I’ll be saving it into my articles folder in FireFox. Thanks!

    Anthony

  3. Jeff Says:

    January 26th, 2009 at 10:35 am

    Animated PNGs: http://en.wikipedia.org/wiki/APNG

  4. admin Says:

    January 26th, 2009 at 10:37 am

    Wow! Thanks Jeff, I didn’t even know that option was out there. Probably isn’t well supportted though.

    Never heard of APNG (Animated PNG)…

  5. Henry Ho Says:

    January 26th, 2009 at 1:58 pm

    Stop using those stupid script already, use PNG8 for backward compatible alpha transparency!

    http://www.sitepoint.com/blogs/2007/09/18/png8-the-clear-winner/

  6. admin Says:

    January 26th, 2009 at 2:59 pm

    Wow Henry! Thanks for pointing that out… this must be one of your habored secrets!

    I use Photoshop and didn’t realize PNG8’s could do transparency!

  7. PNG-8 Alpha Transparency (screencast) :: Brenelz's Web Development Tips :: Winnipeg Web Development Says:

    January 27th, 2009 at 11:20 pm

    [...] by a comment on my previous blog post titled, PNGs, PNGs, and more PNGs I have decided to record a 15 minute screencast to show you how to use PNG-8 for [...]

  8. mario Says:

    January 28th, 2009 at 3:33 pm

    It is also a common misconception, that some browsers support GIFs, but not PNGs. This might have been the case in the 1990s, but doesn’t hold true anymore. I even sort of remember one of my browsers not to display GIFs once (libungif excluded on Debian or something?).

  9. Robert Says:

    January 29th, 2009 at 8:28 am

    Here’s another fix, that works perfect (and you don’t even see it change the pngs). Include the following in your <head>

    and rename all your png files to end with “-trans”. ( Ex: my.png -> my-trans.png)

    Cheers!

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 
connect with me!