0
\$\begingroup\$

In this article it says "Generally speaking, the algorithm behind this format makes some trade-offs to lower the image size."

Just wanted to check that this is referring to image file size, not image size itself, correct? As I have never heard of JPEG compression reducing the actual size of the image.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ I feel like this alone doesn't qualify as an answer but yes. \$\endgroup\$
    – jng224
    Commented Sep 26, 2022 at 14:40
  • \$\begingroup\$ @Jonas Yeah no worries I don't need a big answer, just wanted to be sure I wasn't missing anything. \$\endgroup\$ Commented Sep 26, 2022 at 14:53

2 Answers 2

5
\$\begingroup\$

Yes, and no :)

I think the article is speaking about the image file size (in bytes), and not the image size itself (in pixels) which is indeed unchanged.

But, to be accurate, one of the tradeoffs of the JPEG algorithm can also reduce an image size. In the compression, the RGB image is split into three sub-images, one which is the luminosity component (more or less a black and white version of the image) and two that represent the color information. These three images are compressed separately.

The JPEG format exploits the much greater sensitivity of our eyes to luminosity than to color, and to do so it will scale down the two color images to half size (2x scale horizontally or vertically) or quarter size (2x scale both horizontally and vertically). This is called "chroma sub-sampling". This reduces the amount of data to compress: if a sub-image is 1, without sub-sampling you compress 1 + 1 + 1 = 3, with halved chroma you compress 1 + ½ + ½ = 2 and with quartered chroma you compress 1 + ¼ + ¼ = 1.5, which is half the original size. This of course translates directly into the equivalent file size reduction.

This is usually hardly noticeable, and the "high-quality" JPEGs (Q=98) from my middle-of-range camera have their chroma halved.

In image applications, this sub-sampling is either an explicit option, or is bundled with the "quality" (for instance, chroma is halved for Q=70-90, and quartered below Q=70).

\$\endgroup\$
5
  • \$\begingroup\$ I see, am I correct to say that this is just part of the compression process and the final image produced is the same size as the original input? If so, am I correct to say that the compressed, smaller, colour images are then re-scaled back to the original size? \$\endgroup\$ Commented Sep 26, 2022 at 15:28
  • \$\begingroup\$ Yes on all counts. \$\endgroup\$
    – xenoid
    Commented Sep 26, 2022 at 15:30
  • \$\begingroup\$ Gotcha, I thought I heard that rescaling was part of the JPEG compression process depending on your settings before but I never really knew what role it played as a JPEG had never changed size in my experience, but that answers where that comes from thanks. \$\endgroup\$ Commented Sep 26, 2022 at 15:33
  • \$\begingroup\$ The effects of chroma subsampling are only invisible if the image is sampled higher than it needs to be. If you're viewing at 1:1 it will be glaringly obvious, especially in areas with lots of red detail. \$\endgroup\$ Commented Sep 28, 2022 at 3:02
  • \$\begingroup\$ I am not sure about calling the sub-images images. I would call them channels. \$\endgroup\$
    – Rafael
    Commented Oct 2, 2022 at 21:36
1
\$\begingroup\$

I'm going to assume that when you said, "actual image size," you were talking about the number of pixels.

The image you get by decoding a JPEG file always will have the same number of pixels (and the same pixel dimensions) as the image that was provided to the encoder when the file was created. But see @xenoid's answer which talks about fine details that may be lost.

We often conflate "Resolution" with "number of pixels" (e.g., when we talk about the resolution of some particular image sensor.) The number of pixels puts a lower limit on the size of features in the image that can be "resolved," but when we're talking about a whole end-to-end system—lenses, sensor, image processing, printing—the number of pixels is not the only thing that limits the resolution of an image.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.