Why can two JPEGs with the same dimensions look identical but have very different file sizes?
Asked 6/22/2021
3 views
2 answers
0
I have two JPEG files that appear to be the same image and have the same pixel dimensions/resolution. However, one file is more than twice the size of the other. Even when I zoom in closely, they look equally compressed. What could cause such a large size difference between JPEGs that seem identical?
Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0
Photography Stack Exchange contributor
5y ago
2 Answers
25
The JPEG compression algorithm works like this:
- Instead of being saved as three R, G and B planes, your image is decomposed into 3 planes, one that carries luminosity, and two that carry color (aka chroma) information.
- The next step is called "chroma sub-sampling": the two chroma planes can then be scaled down by a factor of two in one dimension (chroma halved), or by a factor of two in both dimensions (chroma quartered)*.
- The lossy compression is then applied to each plane.
So if you start with an image with N pixels, you initially have:
N + N + N = 3×N
pixels to save. But with the chroma halved you have:
N + ½N + ½N = 2×N
pixels, and with the chroma quartered your have:
1 + ¼N + ¼N = 1.5×N
So, when the chroma is quartered you have reduced the size of the data to a half before even applying the compression. This directly results in a much smaller file size.
Some applications have independent settings for quality and chroma, while others use a given subsampling depending on the quality setting.
*This works because our eyes are much more sensitive to luminosity than to color. Try this (in Photoshop or Gimp):
- Take an image
- Make one copy B&W
- In the other copy:
- Scale it down by 2 in both directions (you can even try a factor of 4)
- Scale it up to its original size. In effect you have blurred your image
- Import the color version as a new layer
- Set it to "Color" blend mode (so the resulting image is the color of the top layer applied to the luminosity of the bottom layer)
You won't see much difference with the initial image.
Originally by user75947. Source · Licensed CC BY-SA 4.0
user75947
5y ago
0
Generated from our catalog & community — verify before relying on it.
JPEG file size is not determined by dimensions alone. Two JPEGs can look the same yet differ greatly in size for a few common reasons:
- Different JPEG encoding settings: JPEG uses lossy compression, and files can be saved with different quality levels and chroma subsampling. More color data retained means a larger file even if the image looks nearly identical on screen.
- Image content compressibility: Smooth areas compress very efficiently, while fine detail, noise, grass, leaves, text, or sharp edges need more data.
- Metadata differences: EXIF/IPTC data, embedded color profiles, or especially an embedded thumbnail/preview can add a lot of size without changing the visible image.
If the files are truly pixel-for-pixel identical, the extra size is likely metadata or a larger embedded preview. If not, the JPEG compression settings probably differ in ways that are hard to see at normal viewing.
To verify, compare the images pixel-by-pixel with a tool such as ImageMagick. Also inspect the files’ metadata to see whether one contains more EXIF data or a thumbnail.
Recommended products
UniqueBot
AI5y ago
Your Answer
Related Questions
Why can photos with the same resolution and format have very different file sizes?
Why can two JPEGs look identical but have different file sizes?
Why can two JPEGs with the same dimensions and DPI have very different file sizes?
Why can two 2000×2000 JPEGs saved at the same quality have drastically different file sizes?
Why can a lower-resolution image have a larger file size than a higher-resolution one?