Is there still any reason to prefer GIF over PNG when creating images for web pages?

15

2

Long ago, I used to avoid the PNG image format when building web pages because browser support was lacking. I remember having a PNG on a page could cause the QuickTime plugin to be loaded - yuck.

Today, every modern browser now supports PNG well and I'm using it in my web pages because:

  • Compared to JPEG, PNG compression isn't lossy. Especially important for logos/drawings/charts.
  • Compared to GIF, PNG isn't limited to 256-colors. Matters a lot with gradients.

In other words, with PNG, my images start looking sharp, and stay that way.

I can still see JPEG being useful because it compresses much better and loses very little visual quality for photos in particular.

And so my question is: What use cases remain for using the GIF file format in web pages? Is GIF now completely obsolete by PNG and its adoption, or are there specific things GIF is still good at?

Chris W. Rea

Posted 2009-10-25T19:15:20.953

Reputation: 10 282

Question was closed 2012-10-05T20:35:51.493

Also duplicate: http://superuser.com/questions/53600/jpeg-vs-png-vs-bmp-vs-gif/296437#296437

– Django Reinhardt – 2013-04-12T14:52:58.460

Answers

15

As far as I know, these are the only reasons:

  • AnimGIF. This animation works everywhere. There's APNG format, but it's not as widely supported, and has no real editing tools.

  • 1x1 transparent graphic, assuming you care whether it's 80b or 120b. That's virtually the only case in which GIF gives smaller file size than PNG.

  • If you don't have proper tools for saving and optimizing PNG files. PNG files may contain color profiles and gamma correction information, which on the web cause more problems than they solve. It's best to have tool that removes this, making files smaller and more interoperable.

IE6 support is a red herring

The confusion comes from the fact that there are several color formats in PNG, and some of them are fully supported, and some of them are not.

  1. Paletted PNG with 1-bit transparency (like GIF): work perfectly in IE6. Without any hacks.

  2. Paletted PNG with 8-bit transparency (not possible in GIF): work partially in IE6 (degrade to 1-bit).

  3. True-color PNG with 8-bit transparency (not possible in GIF): don't work in IE6 without hacks.

I'm 100% sure. I've tested it extensively. I'm using them on my websites. I've even worked on software that manipulates those files.

In short: if picture can be saved as non-animated GIF, it will certainly work as PNG, in all browsers, without hacks.

Kornel

Posted 2009-10-25T19:15:20.953

Reputation: 1 225

1

I'm sorry but I had to downvote. This information is not correct. Please refer to http://support.microsoft.com/kb/294714. You need to apply a filter.

– A Dwarf – 2009-11-09T02:55:37.103

8@A Dwarf: I'm 100% sure that PNG 8-bit with 1-bit transparency (GIF-like) works perfectly in IE6, because I'm using it. Have you even tested it?

What you've pointed is required for PNG 24-bit with 8-bit (not-GIF-like) alpha channel. These are not the same. – Kornel – 2009-11-15T23:13:29.430

5

They're useful for plugin-free animation, like Camtasia screencasts.

enter image description here

From: http://www.codinghorror.com/blog/archives/000583.html

hyperslug

Posted 2009-10-25T19:15:20.953

Reputation: 12 882

And then there is APNG (http://en.wikipedia.org/wiki/APNG), as we were talking about modern browsers...

– Jawa – 2009-10-25T20:44:17.077

APNG, eh? I always thought the job would go to SVG http://upload.wikimedia.org/wikipedia/commons/0/01/Slider_Crank_animation.svg.

– hyperslug – 2009-10-25T22:36:36.210

3

Is there still any reason to prefer GIF over PNG when creating images for web pages?


Only that PNG is not fully supported by some older browsers like IE 6.

According to MarketShare IE 6.0 still holds an impressive 24% of the browser market share, making it the most used browser version. No doubt this is caused by the corporate adoption and traditional slow upgrade policies. But it's a reality you must be aware of.


Note however that if you create flat PNGs, you should be fine. It's alpha-channel and transparent PNGs that are not supported.

A Dwarf

Posted 2009-10-25T19:15:20.953

Reputation: 17 756

Resistance to Vista's adoption has helped allow XP (and its default browser, IE6 ) remain popular. Windows 7, and not Vista, will likely take over XP's user base eventually, so hopefully those numbers will decline. – hyperslug – 2009-10-25T19:34:11.633

1I guess if you tend to use single pixel transparent GIFs in your web designing you might want to stick with GIF as the PNG may show up as a grey dot in IE6. – hyperslug – 2009-10-25T19:46:42.543

2Please look at porneL answer to see why IE6 is NOT a problem for PNG – Vincent Robert – 2009-11-09T01:41:21.530

porneL speaks of 1 color transparent pngs. I speak of full alpha channel transparency. Maybe if you read my answer better? Also see my comment to his post regarding 1 color transparency pngs. – A Dwarf – 2009-11-09T02:54:51.317

1A Dwarf: All GIFs are 8-bit, so you never need 24-bit PNG to represent a GIF image! The fact that 24-bit format doens't work is irrelevant to PNG/GIF debate. You're only spreading confusion. – Kornel – 2009-11-15T23:31:14.553

and 1-bit transparency works. The page you've liked to includes workaround, but not explanation of the issue. The issue has been explained in detail on IE blog, with confirmation that 1-bit transparency works. – Kornel – 2009-11-15T23:39:03.050