4 ms·
> there's no reason to use GIF for any still image - PNG will be superior in all situations For small icons with few colors, I find GIFs to be consistently sma
by avhon1 7y ago
> there's no reason to use GIF for any still image - PNG will be superior in all situations
For small icons with few colors, I find GIFs to be consistently smaller than PNGs.
For example, my website's favicon:
http://alexvh.me/favicon.gif 216 bytes
http://alexvh.me/favicon.png 1041 bytes
- jandrese 7y agoOne 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
- JoshTriplett 7y agoDon'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.)
- jandrese 7y agoI 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.
- JoshTriplett 7y agooxipng 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.
- avhon1 7y agoNeat trick! I exported from GIMP and then used pngcrush. Interesting that this case isn't covered by that workflow.
- beering 7y agoYou are right, I tried creating a 16x16 image with 3 colors and despite my best attempts, the GIF came out to 93 bytes and the PNG 139 bytes. So there are cases where the GIF will be smaller than the PNG. On the other hand, if you are loading enough small PNGs for this to make a difference, perhaps any performance issues that come up might be helped by switching from PNG to GIF.
- beering 7y agoSorry, that should read "might not be helped".