This is something that happens fairly frequently; someone wants to compare PNG and GIF, so they save the same image as a PNG and as a GIF and compare the file size, find the PNG is larger, and conclude that the PNG format itself is not that great.
But what is misunderstood is that PNG supports several means of storing the image losslessly, and many of the programs that "save as PNG" don't even offer you all of those means, let alone making the choice between them visible and easily understood.
GIF images can never use more than 256 colors; they are limited to putting the 256 best colors into a palette, then trying to convert the image to those and only those colors (which is why complex images frequently end up dithered when saved to GIF; the program doing the saving will try to represent a color it doesn't have by juggling patterns of the colors it does have.)
Sometimes the image doesn't need more than 256 colors, and a palette is appropriate. PNG has an "indexed" mode for images like this, and when it is finally compared to GIF apples-to-apples, PNG tends to win out on all but the very smallest graphics.
But PNG also has a mode for rendering images with greater fidelity than GIF can manage -- in fact, it has two; one for grayscale and one for truecolor. In these modes, PNG can represent *any* color, to 8 or 16 bits precision per sample, not just one of a carefully selected set of 256. Because most people who don't know how to select options to get the result they want generally want faithful images rather than small images, most programs that save as PNGs default to saving in truecolor mode -- and while the truecolor mode is what you'd want for images that truly *have* to be reproduced accurately, there *is* an extra expense incurred for making that accuracy possible.
(As an example of how easy it is to misunderstand these options... I have to point out that even Christopher Wright, the cartoonist spearheading this move to PNGs, got it wrong. ^^; He says PNGs only save in 8 and 24 bit images. I think he meant that PNGs in truecolor mode can only use either 8-bit samples (256 different levels of gray/red/blue/green) or 16-bit samples (65536 different levels of g/r/b/g). But in the indexed mode, the one comparable to GIF, PNG uses 8-bit samples for the color, just as GIF does, and can use a palette of as few colors as 1, or as many as 256, just as GIF does.)
P.S. And yes, I am ignoring alpha channels for the moment...
For those concerned about the "virality" of the GPL, a suggestion: Write Your Own Damn Code.
[ Parent ]