Why do JPEG photos have different file sizes even at the same resolution?

In this blog post, we’ll explore why the file size of digital photos varies even at the same resolution, the principles behind the JPEG compression algorithm, and how to choose the appropriate resolution and compression method based on the intended use of the photo.

 

When taking photos with a digital camera, everyone has probably wondered about photo size at least once. This is because even though photos taken in both SHQ and HQ modes have the same size—2048×1536 pixels—the number of photos you can save differs. With some settings, you can only take about 100 photos, but if you change the settings, you can take over 200, which can make you feel like you’ve gained something. Why does the number of photos you can store differ even though the photos are the same size? To understand this, you need to understand the “compression algorithm” used for photos.
Most people are unaware that saving photos to a camera involves compression. While compression is often associated with ZIP files (.zip), the compression process is also a crucial part of image files. Unlike most files that store text or numbers, images contain color information for each pixel, resulting in very large file sizes. For this reason, image files are typically compressed using a compression algorithm to reduce their size before being saved. Later, when you open, edit, or print a photo using various programs, the compressed data is decoded to determine the color of each pixel.
Photos taken with digital cameras are generally in the JPEG format. The full name of JPEG is “Joint Photographic Experts Group,” derived from the name of the group of experts who developed the standard. The JPEG format refers to a digital image file format that uses the compression method standardized by this group. JPEG’s lossy compression method reduces file size by leveraging the visual characteristic that humans are more sensitive to changes in brightness than to subtle changes in color. JPEG compression consists of several main processes: sampling, DCT transformation, and quantization.
The first process is “sampling.” The JPEG algorithm first separates color information into a luminance component and two chrominance components. It then reduces each data component in a specific manner to selectively store only certain color information, while reconstructing the omitted color information based on surrounding data. This process of reducing a portion of the data according to specific rules is called “sampling.” Since the human eye is relatively more sensitive to differences in brightness than to subtle differences in color, JPEG typically employs chrominance subsampling, a method that reduces chrominance information more significantly than luminance information. For example, the amount of data can be reduced by maintaining a higher density of luminance information while storing relatively less chrominance information. This “sampling” process lays the groundwork for the actual compression.
The subsequent “Discrete Cosine Transform (DCT)” and “quantization” are the core components of the JPEG algorithm. The “DCT” is an algorithm based on a mathematical principle that represents data within a given interval as a combination of various frequency components. Instead of storing pixel values directly, converting the patterns of brightness and color changes into frequency components allows the information contained in the image to be represented more efficiently.
The DCT algorithm divides the sampled data into 8×8-pixel blocks and converts the two-dimensional data of each block into a combination of various frequency components. Just as a single function can be expressed as a combination of several sine or cosine functions, the pixel data of an image can also be divided and represented by multiple frequency components. When transformed in this way, important information—such as overall brightness or color changes in the image—is represented by relatively large values, while information such as subtle changes is represented by small values.
“Quantization” is the process of reducing the size of the data by dividing the data matrix that has undergone the DCT process by the values in the “quantization matrix.” Here, the “quantization matrix” is a matrix containing the reference values used in the JPEG compression process. During quantization, small values may be converted to 0 or reduced to even smaller values; this process causes some detail to be lost, leading to a decline in image quality or the appearance of noise. In particular, the more aggressive the compression, the more subtle image details may be lost. Finally, the numbers in the quantized matrix are arranged in a specific order, and “Huffman coding” is used to reduce the data size once more, completing the data to be saved as a JPEG file.
Digital cameras also use this JPEG compression algorithm when saving photos in JPEG format. The resolution and file size of photos saved from a camera depend not only on the number of pixels in the image but also on the JPEG compression settings. Generally, at the same resolution, the stronger the compression, the smaller the file size, allowing more photos to be stored on the storage device. Conversely, applying weaker compression results in a larger file size but makes it easier to maintain image quality close to the original.
Comparing the resolution and file size of photos by mode, TIFF has a resolution of 2048×1536 pixels and a file size of approximately 9,231 kB, while SHQ has a resolution of 2048×1536 pixels and a file size of approximately 1,391 kB, and HQ has the same resolution but a file size of approximately 682 kB. SQ1 has a file size of approximately 249 kB at 1280×960 pixels, and SQ2 has a file size of approximately 62 kB at 640×480 pixels, making them even smaller. As shown, even if the number of pixels in a photo is the same, the file size of a single photo can vary significantly depending on the JPEG compression settings. Therefore, even with the same amount of memory, you can store more photos in HQ mode than in TIFF mode. The reason photos taken with a digital camera often seem much larger than those found online is that images used on the web generally employ compression formats like JPEG to reduce storage space.
When viewed with the naked eye on a monitor, it may be difficult to notice a significant difference between photos saved in TIFF, SHQ, or HQ modes. However, if you intend to print the photos, you should select the size and image quality appropriate for that purpose. The print size and sharpness of a photo depend on how many pixels are arranged within a unit of length; the unit primarily used for this is “ppi (pixels per inch).” Generally, documents use 150–200 ppi, while posters and pamphlets use around 200–300 ppi. For example, suppose you want to print a photo taken in SQ2 mode and mount it on a poster. When viewed on a standard-sized monitor, that photo might occupy about a quarter of the screen. However, if you print the photo at 300 ppi, it will measure only about 5.4 cm × 4 cm. Therefore, it is not suitable for a poster and is better suited for use as a photo in a pamphlet. Furthermore, even for photos with the same number of pixels, a TIFF file with minimal compression will produce a cleaner and sharper print than a heavily compressed HQ file. Since some image information is removed during the compression process for HQ files, fine details may become blurred. This is easy to understand if you consider the principle that some image information is lost during the sampling and quantization processes.
In summary, JPEG reduces file size by compressing photo image data through processes such as sampling, DCT transformation, and quantization. The degree of compression determines how the camera saves photos and the file size of each image. Photos with heavy compression take up less storage space, allowing you to store more photos on a storage device; however, the loss of detailed image information may make them unsuitable for printing or high-resolution output. Conversely, photos with less compression maintain relatively high image quality but take up more file space, which may reduce the number of photos that can be stored in the same amount of storage space. With this background knowledge, if you adjust the resolution and compression settings to suit your purpose for taking photos, you’ll be able to store more photos in limited storage space while maintaining the image quality you need.

 

About the author

Cam Tien

I love things that are gentle and cute. I love dogs, cats, and flowers because they make me happy. I also enjoy eating and traveling to discover new things. Besides that, I like to lie back, take in the scenery, and relax to enjoy life.