Nothing is for sale here. Freewill tips keep the site running. Want to help? → Tip via Paypal

Image Formats for the Web

Image use is an important part of web design. The right images can add visual interest, get attention, provide direction, delineate content sections, and now more than ever, are simply used as a form of entertainment.

There are dozens of image formats, but which are the best to use on the Internet? There are several options, each with its own strengths and best use cases. The choice of image format depends on factors such as image complexity, desired quality, and file size considerations.

Here's the low-down on five of the most commonly used image file types.

JPEG (Joint Photographic Experts Group)
Also known as JPG. These two file type extensions are used interchangeably and are the same thing. This is a widely supported image format that is best suited for complex photographs or images with many colors and gradients.

It achieves compression by selectively discarding image data, resulting in smaller file sizes. Camera photos usually have little compression. You can open the photos in a graphics editor and resave it, setting a higher compression level. However, too much compression can lead to some loss of image quality, especially with higher compression levels. This is a generally a good choice for photographs or realistic images.

PNG (Portable Network Graphics)
PNG is a popular image format for web graphics that supports lossless compression. It is well-suited for images with sharp edges, text, or simple graphics with transparency.

PNG files tend to have larger file sizes compared to JPEG for detailed images, but they retain the original image quality without introducing compression artifacts. PNG-8 is a variant that supports up to 256 colors, while PNG-24 allows for millions of colors and better quality.

GIF (Graphics Interchange Format)
GIF is a widely supported format known for its support of animations and basic transparency. It uses a lossless compression algorithm, but it has a limited color palette of 256 colors, making it suitable for simple graphics, logos, or line art with large areas of flat colors.

However, for complex images or photographs, GIF may not be the best choice due to its restricted color range and larger file sizes compared to other formats.

WebP
WebP is an image format developed by Google that provides both lossless and lossy compression. It supports transparency, animations, and generally provides smaller file sizes compared to JPEG or PNG without significant loss in image quality.

WebP is becoming increasingly popular, but support for it is not as widespread as JPEG or PNG. Modern web browsers generally support WebP, but some older browsers may not handle it natively. Many graphic editors do not yet support the format either, although GIMP and Paint.NET, both free image editors, do support it.

SVG (Scalable Vector Graphics)
SVG is a vector-based image format that uses XML to define images. It is resolution-independent, meaning it can be scaled up or down without loss of quality.

SVG is primarily used for graphics, logos, icons, or any image that requires resizing or scaling. It is not suitable for complex images or photographs, as they may result in dramatically larger file sizes and reduced performance. Inkscape is a free and vector graphics editor that supports SVG.

Support

In terms of support, JPG, PNG, and GIF are the most widely supported image formats across different browsers and platforms. They are considered the safest choices when broad compatibility is important.

However, the best image format for a particular use case depends on the specific requirements of the image, such as complexity, transparency, or need for animation, and on the purpose of the image. Try experimenting saving images in different formats and compression settings to strike the right balance between image quality and file size for a given image.

pro tip An image that is overly compressed can potentially take longer to display on a web page, even though the file size is smaller.

When an image is compressed, the file size is reduced by removing or simplifying certain image data. This compression is typically achieved by discarding some of the finer details or by using algorithms to optimize the image data. However, if the compression level is too high, it can lead to a noticeable loss in image quality, such as artifacts, blurriness, or blocky pixelation.

When a web page loads and displays images, the browser needs to download the image files from the server and render them on the page. If an image is heavily compressed, the browser may need to spend additional time decoding and processing the compressed data to render the image accurately. This can result in a delay in displaying the image, especially on slower devices or with limited processing power.

I find the best tact is to compress an image until the loss of quality is noticeable, and back off from that some. For example, if I'm saving a JPG and notice a loss of quality at a compression level of 30, I'll save it at a compression level of 35-40, depending on the image. (A higher number means higher quality in Photoshop, which is what I use.)