Saturday, March 04, 2000

GIF versus JPEG

jestr wrote:
> Would you recommend .gif over .jpg?
> I thought .gif was mainly for animated bits.

For pictures with large solid-color areas and a modest palette, yes, I would strongly recommend GIF over JPEG format. For pictures with gradual-toned ("gradient") areas and thousands or millions of colors (like a photograph or a painting), I'd recommend JPEG format. (For a posting copy only-- you should always save the original in your paint program's native format. More on why in a bit.) I use each format when each is called for-- see my gallery site blog for examples of both.

Using the picture you posted as an example: The original BMP was 393,190 bytes; your JPEG was practically as big at 386,709 bytes; and a copy saved as a GIF was 70,080 bytes. (!) That is significant, since your entire audience is not on high-speed connections. The GIF also perfectly replicates every pixel in your original BMP, while the JPEG has changed and recolored some (zoom in and compare) as part of its compression method. That is to say, JPEG is a "lossy" algorithm, which is why you NEVER use it for a master copy-- ONLY for publishing to the web. Since you used just 102 colors in your original, that fits comfortably within the 256-color palette allowed by GIF.

Side note: PNG is another non-lossy format, but with less restrictive palette limitations-- IIRC, it can encode 24-bit color (16M colors) with an 8-bit transparency channel (for nice semi-transparent shadow effects, etc.)-- but it's not as widely supported (yet) as GIF and JPEG.

It was immediately obvious the first time I saw this picture that it belonged in GIF format-- this is exactly the kind of image that GIF was designed for. And a photomanip or painting or solid-modeling computer rendering just as obviously calls for JPEG. If an image is kinda in the middle regarding "solid vs. gradient" color areas, try saving both GIF and JPEG copies, and see which is smaller and/or looks better.

Hope this helps.


No comments: