How to Reduce JPEG File Size
In the world of digital image storage, JPEG is one of the most common ways to encode information. While it may be most familiar to you in the form of a .jpeg
or .jpg
file extension (read more about the difference between JPG and JPEG), JPEG is actually a means of compressing, or reducing, the size of an image.
Of course, an image file might still be too large for your purposes even after it's been encoded as a slimmed-down JPEG. This article is all about how to reduce JPEG file size to deliver the most optimized JPEG images.
A quick intro to JPEG
The JPEG format was named after the Joint Photographic Experts Group, a committee that initially created the standard in 1992 and has maintained it since. As of August 2016, JPEG files account for about 45 percent of all image requests fielded by the web's most-trafficked sites, according to the HTTP Archive.
Some important characteristics you should know about JPEGs include:
- Widespread adoption in devices such as DSLR cameras and phones
- Embedded color profiles and EXIF metadata, such as GPS locations
- Lack of transparency layer like the one available in GIF and PNG formats
How does it work?
JPEG is a form of lossy, or irreversible compression. This means it doesn't represent data in a new format from which the original can later be retrieved, like a ZIP file does. Instead, JPEG rewrites data by discarding some of the information.
During JPEG compression, a complex mathematical operation called a Discrete Cosine Transform, or DCT, samples and re-encodes the individual colored pixels to produce a new file. The result can have a different resolution, quality or both.
Why reduce JPEG size?
Web connections take time to transmit data, this is known as latency. One of the reasons why JPEG images are popular online is because you can choose various compression settings. This lets you create websites that get your visual point across without making your users wait forever to load bloated sized images.
Bandwidth can be costly and since images account for the largest sized assets of an average website, reducing their size can be both beneficial for the visitor as well as the website owner. The more you reduce file sizes, the more you minimize load times and costly HTTP requests. Optimizing your images can also reduce operating costs by ensuring you pay for less server space. However, be aware that if you compress the image too much it will be noticeable to the average reader. Finding a happy medium between a small file size and image quality is important.
Tools to reduce JPEG file size
Fortunately, you don't have to master the math behind DCT or shrink your images down to the lowest-possible resolution to capitalize on small JPEG file sizes. If you're WordPress user, you can install the Optimus plugin to automatically optimize your JPEG images as you upload them. Additionally, you have the ability to bulk optimize existing images, optimize thumbnails, convert to WebP and more.
The vast majority of image editors also allow you to define different JPEG quality levels. In most cases, maximum image quality corresponds to the least compression. Here are a few additional handy resources to keep in your toolkit:
- Photoshop - This component of Adobe's Creative Cloud suite is one of the most well-known raster-image editors out there. When saving files in JPEG format, the settings and preview dialog box displays options that let you tweak compression quality and preview the size of the finished results. For large operations, you can also try Adobe Bridge.
- GIMP - The GNU Image Manipulation Program is free software that lets you edit raster images. It also provides functionality for choosing compression settings as you export and save your work. It runs on most operating systems.
- ImageMagick - ImageMagick is notable for running on Android and iOS in addition to Linux, Mac OS X and Windows. You can use it to resize as well as convert, animate or transform images.
- OS X Preview - If you're on a Mac, the default Preview application that comes with the OS X operating system can perform JPEG re-compression. When exporting as a JPEG, use the slider indicator to pick a quality level and file size that works for you.
If you're a webmaster with a lot of image assets, some of the preceding tools may be too slow. Those running Linux servers, maintaining corporate intranet sites or simply more comfortable with the command line should investigate libraries and scripts such as:
Summary
This article is an introduction to JPEG optimization, however it should help you in answering the question "how to reduce JPEG file size". There are plenty of tools available in the form of online tools, plugins and extensions, as well as APIs to reduce JPEG file size. Choosing one that is easy to use, and works best for your use case it up to you.