The mighty JPEG: born in 1992, it is still one of the most commonly used formats for creating photos and images. It’s also a go-to format for document generation and archiving, photo archiving, and data normalization for a number of popular digital asset management systems.
You might be asking yourself, “What can’t JPEG do?” Well, when it comes to image compression, the answer is, it depends. In this post we’ll explore the pros and cons of compression via JPEG.
Note: If you are using TIFF and are not explicitly specifying an internal format for your data, your file may very well default to JPEG, so this post may also for you.
For our purposes, we’ll focus on the most widely used method of JPEG compression: lossy. The lossy method provides a high degree of compression, resulting in a smaller file, but it comes at a cost, as data from the original file is jettisoned during compression. The smaller the file, the bigger the visual effects of data loss—and the loss is irreversible.
So what are you sacrificing? To answer this question, we’ll need to take a look at how JPEG works.
If we zoom in on a fairly small photo (the one below is 320×240 pixels and 84kB) we can easily see that what at a distance looks like one uniform image is actually a series of pixels. Each pixel typically has up to four bytes of data, which specify its color.
Understanding the mechanisms behind lossy compression requires a bit of math, but what is most important to note is that each lossy compression scheme has its own definition what data is most important, which it retains, and what is least important, which it throws away.
With JPEG files, lossy removes high-frequency details from each block of pixels. The result is a smoothing out of the sharpness of each block, which can alter an image substantially.
Compare the photo above to the more compressed version below. The more compressed version has overly smooth areas and discrepancies in both color and pattern.
Now let’s take a look at what happens to the quality of the same image during progressively higher levels compression.
Mid quality (19kB)
Low quality (14kB)
Extremely low quality (11kB)
Keep in mind that these photos are fairly small in size compared to what today’s scanners and cameras can easily produce. So, given that JPEG smooths a small percent of the size of the total image at a time, if you save a much larger image at mid to low quality, your compression distortions may not be as noticeable on a comparably small screen or device.
For example, the image below, which is 4320×3240 and 1000kB (about 20% of the size of the original) was saved at a relatively low quality. Although some compression artifacts are visible, it looks fairly good when scaled down for display:
However, when compared to the full-sized version compression artifacts are easily observable and will likely be displeasing. Here is a small section of the full-size image. The effects of compression are easy to see:
Beyond understanding and choosing the compression quality, you must also decide whether JPEG is right for your image to begin with. For example, JPEG was designed for natural images, such as the photos above, so it doesn’t necessarily work well on data from text or line drawings, as shown by the blurriness in the image below.
And remember, you can never recover or increase image quality post compression. So, even at the highest quality, your JPEG-formatted data will not be equivalent to what was contained in the original image file.
So, can you control image quality during compression? Yes and no. Scanners and cameras typically don’t give you the option to adjust image ratios; they generally choose the best available quality.
Conversion software may have variable settings but typically your best option is to save at the highest quality possible. However, if you are saving personal photos and have very limited storage space, reducing image quality even a small amount can save significant room.
Similarly, if your institution is archiving images or documents and the large-scale content is a higher priority than the low-level details, saving at a lower quality may be the perfect solution. Just make sure your customers will tolerate a bit of blurriness to be able to read the contents of a document!
A better question to ask might be when is JPEG perhaps not the best option? As we saw above, JPEG is generally not suitable for compressing text-based and structured images such as text and line drawings. And if low-level details are vital to preserve, as may be the case with scientific data or archival photos, there may be format choices that better represent each individual pixel at expense of space.
If the file is part of an ongoing project, and its data is being generated from a program, like a graphics or CAD application, it is often better to save in a format that is easier to manipulate, such as a vector format or PNG. Obviously, your choices must always be weighed against the popularity and potential longevity of the file format, as well as some other influencing factors, which we’ll discuss in upcoming posts.
If preservation of data details and metadata or having the ability to manipulate data files is important to you, Bevara offers a solution that eliminates the need to convert at all. For an overview of how our patented data preservation process works, download our white paper.
Questions? Contact us at firstname.lastname@example.org. We’ll either answer you directly or address it in a future post.