Hacker News new | ask | show | jobs
by jandrese 2511 days ago
One of the problems with PNG is that many applications default to full-color-with-alpha-channel as the only save method, even though PNGs can do paletted images just as well as GIF and end up basically the same size. So people look at their PNG files and wonder why they are so big compared to the old GIFs because their application sucks.

Edit: I just tried it with your example:

% giftopnm favicon.gif | pnmtopng > favicon.png

pnmtopng: 5 colors found

% ls -l

-rw-r--r-- 1 jandrese jandrese 216 Aug 7 17:33 favicon.gif

-rw-r--r-- 1 jandrese jandrese 255 Aug 7 17:33 favicon.png

2 comments

Don't forget to run oxipng or optipng, as well; pnmtopng doesn't produce optimal PNGs.

(In this case, it just saves 3 bytes, but it can make a huge difference sometimes.)

I actually pngcrushed the result after that just to see how many of the remaining 39 bytes I could get back, but had the same result. PNG has just a smidge more fixed overhead than GIF.
oxipng got it down to 248 bytes. And yes, PNG has a little more fixed overhead, such as the IEND chunk and some of the required IHDR metadata. That only tends to be an issue in files this small, though, and gets dwarfed by potential savings in larger files.
Neat trick! I exported from GIMP and then used pngcrush. Interesting that this case isn't covered by that workflow.