3
Use the correct file format
There are four major file formats for saving out images and graphics for the web: JPG, PNG, GIF and SVG. Each file format has its benefits, drawbacks and intended use case.
Your image or graphic should be saved to a particular format based on if it’s a raster or vector. Raster images are created with pixel-based programs or captured with a camera or scanner. These images have a finite number of pixels and can lose quality when scaled larger.
JPG, PNG and GIF are formats best suited for raster images. Vector graphics are created with vector software and can be infinitely sized without losing quality. SVG and GIF are best suited for vector images, while you can also save a vector graphic as a JPG or PNG, however you lose the ability to scale your graphic infinitely.
JPG
JPG or JPEG is the most common raster file format for images.
Pros
- Smallest file size
- Best for high quality photos
- Compatible on web and any device
Cons
- Image quality can be greatly reduced if compressed too much
- JPGs do not support transparent backgrounds
When to use JPG
JPGs are best for non-moving photos and other files that don’t require transparent backgrounds. Avoid using JPGs on colored backgrounds.
PNG
PNG is another common raster format that is more versatile than a JPG. PNG can support more colors (over 16 million) and support transparent backgrounds, or an alpha channel.
Pros
- Ability to have a transparent background for layering your image on colored backgrounds
- Can be compressed without losing as much quality as a JPG
Cons
- File sizes tend to be larger than JPG
- Does not support animation
When to use PNG
PNGs are best for graphics with sharp edges, text graphics, logos, icons and other designs. Use a PNG for graphics that need to be placed on non-white backgrounds, such as all-white logos on a black background.
GIF
GIF is a raster format that allows you to have animated images. Images are sequenced on top of each other to create motion.
Pros
- Ability to create animated images and messages
- Supports transparent backgrounds
Cons
- Image quality and file size are tied to the number of colors. More colors in the image will have a sharper image but larger file size. Less colors in the image will have a grainier image but smaller file size.
- You’re limited to using an image with 256 colors.
When to use GIF
GIFs allow you to have the flexibility to display multiple images and interesting transitions in the same graphic. However, avoid using photos and graphics with many colors if you need a small file size.
SVG
SVG is a vector format that allows you to have sharp graphics and manipulatable objects on the web. SVG can be created and edited in vector programs such as Adobe Illustrator or Figma.
Pros
- Small file size
- Infinite sizing (vector) without losing quality
- Flexibility for developers (can change settings including color and size)
- Can be edited by in a vector program such as Adobe Illustrator
- Supported in Microsoft Office products for graphics
- Can be animated
Cons
- SVG files are not ideal for displaying high-quality digital photos
- Older browsers such as Internet Explorer cannot support SVG images
When to use SVG
SVG can be used for logos, icons, graphics and other illustrations used on the web. Graphics can be stretched and compressed without compromising quality and look great on mobile devices with high pixel density displays (see more below).