6

Is there any reason for using GIF instead of PNG when the image requires only 1 bit transparency (either on or off) and of course no animation is required?

thanks

3
  • 1
    GIFs are more limited in what they can do (excluding animation vs PNG) but they take up less space. If you're just using simple images, and you'd want to eliminate just one color (like a white background) a GIF will save you space. But for more advanced transparency, use a PNG.
    – Hanna
    Commented Mar 12, 2011 at 21:35
  • GIF is better supported in older browsers.
    – horatio
    Commented Mar 15, 2011 at 14:25
  • 2
    @horatio: Even IE6 supports PNGs with 1-bit transparency.
    – e100
    Commented Mar 17, 2011 at 13:30

4 Answers 4

9

No, GIF for static images is a waste of bandwith. PNG can almost always be much smaller than GIF

  • GIF has a very poor compression algorithm, but has a smaller header.

  • PNG has a few bytes more of overhead for extensible metadata, but has a superior compression algorithm.

So the larger the image, the bigger advantage PNG has. Basically only images like 1x1 spacer are going to be smaller in GIF.

It doesn't matter whether image has transparency or not — in every case PNG can compress pixels better.

However, there are programs that don't fully take advantage of PNGs compression capabilities and Photoshop is one of them.

You can fix Photoshop's poor PNG compression with a PNG optimizer such as PNGOUT or ImageOptim.

1
  • 2
    and as you pointed out in another thread elsewhere, png-8 supports alpha transparency with a graceful fall back. This is a huge win over gif.
    – horatio
    Commented Mar 5, 2013 at 16:53
2

PNG is similar to GIF in many ways but even better in others. It is lossless like GIF but supports 8 and 24 bit color, unlike GIF which only supports 8. PNG supports one-color and alpha transparency, whereas GIF only supports one-color transparency. PNG uses various compression filters to minimize overall image size and can apply different filters on a per-line basis to achieve higher compression. The big attraction to PNGs is its ability to do alpha transparency.

They both work better with large lines of the same pattern or color.

So no great difference for 1 bit transparency whether you use gif or png.

4
  • The size of a PNG will always be a bit bigger than GIF.
    – Joris
    Commented Mar 12, 2011 at 14:30
  • 2
    @Joris This depends entirely on the application/algorithm that is being used. There are some tools that are able to compress png resulting in more compressed images. I once had such a tool.. It was command-line based and ran only in linux but the compression was awesome. pngs were between 1/3 and 1/4 less in size than their gif counterpart.
    – leugim
    Commented Mar 13, 2011 at 6:46
  • when the image require only 1 bit transparency the size will affect only in bit kb's.so it depends on image if it have more detail png will be bigger then GIF.
    – Jack
    Commented Mar 14, 2011 at 4:42
  • 2
    @Joris: PNG supports 1-bit color key, just like GIF, and the DEFLATE algorithm and various pre-filters applied to PNG is generally superior to LZW, so the assertion that PNG is always be bigger than GIF is dubious. When you're storing the same image (not a full color PNG vs jittered GIF) and you use a good PNG compressor (not Photoshop's or Paint's), it's very rare for GIF to beat PNG.
    – Lie Ryan
    Commented Mar 5, 2013 at 11:35
0

If you're worried about size, GIF tends to be a bit smaller (it depends, of course).

Although, I prefer PNGs because of their versatility. I like to keep it consistent, so all my (static raster) images are in PNG.

-1

GIF is a smaller size than PNG. I hate GIF personally because I use larger bit transparency. Hope this is the answer to your question.

2
  • Is it? If I save for the web appropriately I can achieve the same size more or less.
    – cherouvim
    Commented Mar 12, 2011 at 10:49
  • Normally GIF files are smaller than PNG. But again, I recommend PNG because you can have much higher detailed images with it.
    – Joris
    Commented Mar 12, 2011 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.