Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Web Development
Expertise: Beginner
Mar 11, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

JPEG and GIF -- which to use, and when?

The graphics on my Web pages are all now in GIF format. Someone told me that I should convert all these GIFs over to JPEG format, because it is faster and better. Is this true?

Not necessarily. It depends on the kind of image.

The JPEG graphics format is certainly a more "high-tech" format, in that the mathematical algorithm used for image compression is more complicated and harder to implement, which is why the early versions of Web browsers only supported inline GIFs. In those early days, you could only view JPEG images via an external viewer or helper app.

Now every browser supports inline JPEGs, leading some people to think you should convert all your graphics to this more advanced format. However, different compression algorithms behave differently depending on the image data. There are many situations in which GIF is the better format.

GIFs are good for computer-generated graphics, for example those generated by drawing programs like Adobe Illustrator or MacDraw. Typically, these graphics have large flat or evenly shaded areas, with not a lot of detail or surface texture. Because the GIF algorithm looks for repeating sequences of pixels, it will compress these kinds of images very well.

JPEG on the other hand, was designed by the Joint Photographic Experts Group, and is suited more to photographic or natural-looking images rather than computer illustrations. These photographic images tend to have a lot of texture and irregular shapes. Because the compression algorithm does not depend on repeating sequences of pixels, it works better for these kinds of images than GIF compression.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date