9
\$\begingroup\$

I want to crop a JPEG file in Lightroom and export that cropped file to another JPEG so that I can e-mail it. The exported JPEG should have the same quality as the original. I don't have the RAW file available anymore.

When I export the file I choose JPEG as an export format. But now I'm wondering if I should set the quality to the same quality as the original JPEG (= 80), or to 100.

I'm not sure if Lightroom reapplies the compression to the JPEG, i.e.:

RAW -> compress to quality 80 -> JPEG file 1 -> compress to quality 80 -> JPEG file 2

Or that it decompresses the JPEG and recompresses it again, effectively giving the same quality:

RAW -> compress to quality 80 -> JPEG file 1 -> decompress to bitmap -> compress to quality 80 -> JPEG file 2

How does Lightroom handle this?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Do what you have to do to get the image you need while maximizing quality. It is best to always go lossless to lossy only once, but if you can't help it... still better to have the image than not. \$\endgroup\$
    – Phil
    Feb 1, 2013 at 18:52

3 Answers 3

19
\$\begingroup\$

The image will be recompressed. The two scenarios you describe are actually effectively the same, because the lossy part of the JPEG compression discards information which stays gone when the image is decompressed. (Hence, lossy.) That means that reapplying with the exact same parameters shouldn't do much, either in terms of further space saves or in terms of further artifacts. The differences come down to precision and rounding errors. (This is the same in Lightroom as it is in any other program.)

So, if you recompress with exact same parameters and have aligned your crop to 8×8 blocks, the degradation should be minimal. However, if you're using a high level of compression (I think 80% qualifies), you might actually see a difference, because the artifacts introduced by the initial compression are permanent changes to the image and will get recompressed too, possibly causing more artifacts.

Setting to 100 will be more safe, as any newly added artifacts will be hard to notice. It won't make the image any better, but not significantly worse. However, it will introduce changes across the whole image, whereas resaving will mostly concentrate changes to where artifacts are already noticeable. This, unfortunately, means that your mileage will vary.

If you're resizing or have made significant manipuations, all bets are off.

See this answer for details on how bad this degradation can get (and how to minimize it).

\$\endgroup\$
4
  • \$\begingroup\$ Um, note that I made a major change to this answer after it was accepted. :) \$\endgroup\$
    – mattdm
    Feb 1, 2013 at 19:14
  • \$\begingroup\$ Yes, thanks for the elaborate answer. I wish I could vote it up again :) \$\endgroup\$ Feb 2, 2013 at 0:19
  • \$\begingroup\$ @mattdm, Is lightrooms compress to 80% quality mean high compression is being used? \$\endgroup\$
    – PatS
    Dec 31, 2019 at 20:48
  • \$\begingroup\$ It's subjective, of course, but for the purposes here I'd consider that high compression. \$\endgroup\$
    – mattdm
    Dec 31, 2019 at 22:26
4
\$\begingroup\$

So how it works in theory?
First, when you hit save button, there is conversion between RGB to YCrCb color system. If you implement this badly, here is your first step of data loss. There are practical reasons why this conversion is needed but it not crucial here. After this conversion, from every pixel value is subtracted value of 128 to create zero-mean image.
After conversion RGB to YCrCb is finished, you image is divided in blocks of 8x8 pixels, which are called blocks, or MCU (minimal coded unit). After your image is divided in 8x8 blocks, then Forward Descreete Cosine Transform is executed on every 8x8 block. Formula of FDCT is given bellow:
FDCT

where M and N are dimensions of the 8x8 block, in our example M=N=8, and C(u), C(v) are constants which is given in picture bellow:
"Constants

F(u,v) is result of FDCT, which is also matrix/block 8x8 pixels, and F(u,v) elements are called FDCT coefficients, and they are frequency representation of the picture. First element F(0,0) is called DC coefficient, and others are called AC elemts. First element is most important because it hold most of data of 8x8 block. If we do some math we can get that first element F(0,0) is mean value of all other nodes, multiplied by 8 which is described in formulas bellow. FDCT math Mean value
and you get
Value of F(0,0)



Enough of mathematics :).
If you are following me, then you see that we didn't loose so much data until now (we can still run IDCT (I-inverse) and we will get our starting image with some losses). So where is the process, what is changing when you are setting your Photoshop/Lightroom quality size when you are saving .jpeg image? Let's continue.

So lets say we have image 16x16 pixels. When we divide our image to 8x8 blocks, we get two 8x8 blocks. After we do color conversion, we get to FDCT. We run FDCT on first 8x8 block, and as resoult get new 8x8 block, which is product of FDCT. Then we run FDCT on second 8x8 block of original image, and as result, we get another 8x8 block of FDCT. So altogether, result of FDCT on our 16x16 picture/matrix is new 16x16 matrix and lets call it F matrix.

Now F matrix is divided in 8x8 blocks, and it is divided with quantisation table which is matrix of 8x8 pixels. Quantisation table values are constants/numbers which are given by experimental results on human eye. Classical quantization table is given bellow.
quantization table

This matrix which is called Q matrix, is divided with our F matrix, actually first 8x8 block of F matrix, then with second 8x8 block of F matrix, and so on. Why? To get smaller numbers, for which we need fewer bits to represent them in digital file. If you have value 105, you need 8 bits for digital representation. But if you devide 105 with 52, then you get 1,90. You take only integer part, which is 1.00. Representing decimal number 1 you need one bit only, so you saved 7 bits. Now imagine savings for picture with 4000x4000 pixels :).

This process of dividing F table with Q table is spot where jpeg loss is happening. If Q elements are bigger, loss is bigger and vice versa. So when you changing Photoshop spinner from bad to great quality, actually you are changing values of Q table.

Also, you see that first element of Q matrix, Q(0,0) is smallest one. It is because this element will bi divided with F(0,0) element, which is DC element (element which holds most of data), and if we divide it with big number, you will see 8x8 blocks in your image, as you can see it in pictures posted by @mattdm.

Your answer is yes it is :)

I hope I helped you :)

\$\endgroup\$
2
\$\begingroup\$

As Mattdm said, JPEG is an image format that will loss its quality after each re-saving. This is a price that we pay for the resulted small image file size.

But JPEG also allows some loss-less operation including, Rotation (90, 180, 270 degress), Flipping (Horizontal or Vertical) and Cropping . Not sure whether LR allows to save JPEG images loss-lessly, but there are some third party tools that allows it, for example: FastStone Image and BetterJpeg.

A minor drawback: when cropping lossless, images of sizes which are not a multiply of the JPEG block (16 × 16 pixels for color images, 8 × 8 pixels for grayscale images) have to be cropped to the block boundary, which is mostly not exact there where you have selected.

\$\endgroup\$
4
  • \$\begingroup\$ You aways lost some of the data, because using FDCT (Foreward Discrete Cosine Transformation), whatever program you use. It depends on quantization table. If numbers are greater in quantization table, your lost is bigger, and vice versa. \$\endgroup\$
    – D4Am
    Feb 4, 2013 at 14:03
  • 3
    \$\begingroup\$ the lossless operations don't decompress the image, it just moves the block order around or remove them (crop). \$\endgroup\$ Feb 4, 2013 at 17:13
  • \$\begingroup\$ Nice to know that! \$\endgroup\$
    – D4Am
    Feb 4, 2013 at 20:08
  • \$\begingroup\$ actually, it does decompress partially to expose the DCT coefficients...but keeps the quantization table intact. \$\endgroup\$ Feb 4, 2013 at 23:20

Your Answer

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

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