Skip main navigation

Image formats

An introduction to the main image formats and compression, with advice on what image format to use and when

Image file formats

There are a number of file formats we commonly encounter when working with digital images. Here we will look at a few properties of the most common ones.

Where the descriptions below mention compression, this means the format includes a way to shrink the size of the image data when stored as a file. There are two kinds of compression – lossy, where data is lost in the compression algorithm, which typically have a smaller file size, but data cannot be recovered and is lost forever. Alternatively, lossless compression can be used, which does make for a smaller file size than the original image, but also preserves all image data.

JPEG – .jpg, .jpeg

JPG files were designed in the 1990s as an efficient way to store digital images. These files are compressed using a form of lossy compression which does degrade the appearance of an image. The quality level of this compression can be set at the time of saving, providing a trade-off between file size and quality of image data. One feature of JPG compression is it is designed to make images look good to humans – so it is designed to make typical everyday photos still look nice whilst reducing file size. One way it does this is to reduce information representing colour information, which actually we, as humans, cannot resolve well. Our visual system is able to resolve edges of objects well, but cannot resolve colour so accurately. Whilst this feature is a benefit when reducing the size of everyday photos, it can be problematic for scientific data, as data can be corrupted whilst still appearing high quality to the human eye. Still, with a high-quality setting, a JPG image is still a viable format depending on the kind of analysis that will be required. The JPG image format is less well suited to precise images such as line drawings or fine linear structures, as the data compression performs less well in this case. Also, be aware that repeatedly resaving a file as JPG when small changes are made can degrade image quality across the whole image. A later variant, JPEG2000, has been proposed as a successor this format, but original JPGs remain the most popular variant.

PNG – .png (Portable Network Graphics)

These images, often pronounced “pings”, offer a form of lossless compression. They support colour and greyscale images, as well as supporting ways to represent transparency in images. Regions of transparency can me masked out using alpha channels. This represents an extra channel of data in the image which can be used to set a mask for level of transparency across the image. PNG files are efficient at representing images like icons and barcodes. They can be used to store photos but compressed size is typically larger than JPEG, as JPEG files are lossy. Being lossless, files can be opened, edited and resaved repeatedly without losing data quality though.

TIF, .tif

These files are a container format which can be extended to include a wide range of options. They contain header information, essentially a text section of the file which describes the kind of data the TIF file contains, and the properties of how it is stored. For example, TIF files can be used to store compressed images, even image data in other formats such as JPG, although this is quite rare. Alternatively, data in TIFs can be uncompressed, or use lossless compression such as LZW, which replaces repeating patterns in images with smaller ID numbers, saving space. Therefore, TIF files are a very flexible format. TIF files are often used to store uncompressed or lossless-compressed data in phenotyping. The header text can be used to store metadata about both the file type and the details of the image capture – again useful for phenotyping as it can store details such as the settings of the camera at the time of capture.

GIF .gif

GIF files represent one of the earliest popular image formats. The format is largely replaced by PNG for images today, though GIF does have a niche in supporting animations. GIF is not a commonly used format for scientific imaging, and in most places an alternative format would be more appropriate.

BMP .bmp

Bitmap files are an early example of a format which was designed to make the storage and exchange of image data simple and reliable. It was a widely supported format thanks to it’s simplicity and support, especially within Windows-based software. Despite being a popular format for image processing in the early days, today needs are often better served by a more up to date file format.

Vector graphics (e.g. SVG)

All of the above image formats are raster-based. That is to say their foundation is a 2D representation of the pixels in the images. Other image formats can be vector-based. Vector image formats represent lines and shapes in images as mathematical descriptions, for example defining curves on objects in terms of control points and equations rather than pixels. Although not commonly encountered in digital imaging, sometimes vector formats can be used to mark regions and labels in an image, though still this is not common. One advantage of a vector format is you can zoom in an almost infinite amount with no loss of quality of lines; they do not become blocky like rasterised images. For this reason, they are often used in graphic design printing, allowing for very high quality prints. There are several file formats of vector graphics; a common format is .svg, or Scalable Vector Graphics.

More information

Image formats, and data formats in general, will be considered in more detail in the data handling modules in the DataCAMPP set of courses (coming soon).

This article is from the free online

Introduction to Image Analysis for Plant Phenotyping

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now