6
\$\begingroup\$

Am I losing quality of the pictures when the size of the file drops?

My daughter is sending me some JPG pics to edit for her. The file sizes start around 11MB & 3264x4928. After I do some mild teeth whitening, lint removal, and cloning to fix a few things the file size drops to between 1.5-3MB though the resolution stays the same. I'm saving them at the highest quality it gives me (I think). I've used Adobe CC and am currently using GIMP.

I've read through many of the posts but they are way over my head. If I need to keep them up near their original file size I'm not sure what I'm doing wrong.

\$\endgroup\$
9
  • 3
    \$\begingroup\$ Do you mean MB (MegaByte) instead of MP (MegaPixel)? \$\endgroup\$ Nov 19, 2017 at 18:39
  • 1
    \$\begingroup\$ obviously megabytes, "file size drops to ... MP though the resolution stays the same" \$\endgroup\$
    – szulat
    Nov 19, 2017 at 18:40
  • 1
    \$\begingroup\$ Possible duplicate of What are jpeg artifacts and what can be done about them? \$\endgroup\$ Nov 19, 2017 at 18:48
  • 3
    \$\begingroup\$ Can you post the settings you're using in the Gimp export dialog? \$\endgroup\$
    – mattdm
    Nov 19, 2017 at 19:34
  • 1
    \$\begingroup\$ Re-saving a JPEG file almost always results in a smaller size and less quality. However, if you use the highest quality possible, the loss is very small. Inidividual pixel will have slightly different colors, but overall the difference will be unnoticeable. If you really care about any possible loss of quality, don't use JPEG. PNG is probably the most largely supported alternative. \$\endgroup\$
    – IS4
    Nov 20, 2017 at 13:33

3 Answers 3

2
\$\begingroup\$

You lose quality every time you save a jpeg file: JPEG is what's referred to as 'lossy compression'.

But that's okay - with the original file size you describe, the image is, for your purposes, as good as a losslessly compressed one.

What makes JPEG compression 'lossy'?

Simply put, JPEG reduces the detail of the picture, attempting to reduce the kind of detail that is the least noticeable to a human person. With higher quality settings (resulting in larger file sizes), the loss of detail may not be noticeable at all. With lower quality settings (resulting in smaller file sizes), it will reduce fine details (like small leaves in a tree, hair, freckles) and introduce compression artifacts (well illustrated in the Wikipedia article on JPEG).

When you open a JPEG, it is decoded (because the program does the editing on an uncompressed copy of the picture in the computer's memory), but that doesn't make the picture quality any better: If you open a low-quality JPEG in your picture editing program, the artifacts stay and the details remain lost.

If you save the picture again, the program takes the uncompressed picture from its memory, and applies another round of JPEG compression to that picture with all its artifacts and lost detail, getting rid of more detail and introducing more artifacts.

So if you compress an picture at high-quality settings multiple times, each compression will reduce the picture's quality. There are YouTube videos that demonstrate the results of repeated JPEG compression.

What's been lost stays lost forever, and each round of compression adds to the loss - a little loss for high quality settings, a lot for low quality settings. Even if you open a highly compressed (low quality settings) JPEG and save it again with lower compression (i.e. higher quality settings), you'd get a larger file with lower quality.

Why is JPEG still 'Good Enough'?

As I said in the beginning, all is not lost for what you're doing. While it would be preferable to get pictures in a RAW format (losslessly compressed from the camera's chip), this is far more important for changing the brightness or colors of the image; retouching a picture suffers far less from previous lossy compression.

I wouldn't obsess about files sizes too much. The file size of the original picture may simply be way overkill, with a little more compression still producing virtually identical quality. (Of course this is good for you, as the picture you're editing hasn't lost any fine detail or introduced any artifacts yet.)

Experiment a little with different JPEG compression options, and you will probably notice that with high enough quality settings (e.g. 90%) you'll get good results - the quality of the original image won't be noticeable decreased, even if you zoom in and compare specific parts of the image.

RAW editing adds another layer of complexity to editing pictures too - not least of all because you'll need a different program, as GIMP can't do RAW if I recall correctly.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Byte Commander's has a very helpful suggestion as well, which is to save losslessly while editing. Even though you may have a lossy JPEG source, while editing you may wish to save the current state of the edited picture. Do this in TIFF or BMP (any lossless format really) to avoid further compression losses, and once you're done with the editing, save as JPEG with a compression that keeps enough details to decrease filesize. Think of it as 'lossless editing' before 'lossy publishing'. \$\endgroup\$
    – Arne
    Dec 11, 2017 at 10:20
17
\$\begingroup\$

JPEG is an image format with lossy compression.

This means, every time you save a modified JPEG image, its quality gets slightly reduced because the algorithms used for encoding and compressing the information (namely DCT - discrete cosine transform) do not work pixel-perfect but only store the most important (depending on the quality/compression level) information to reproduce an image that looks basically the same to the human eye, in order to reduce the file size.

To my knowledge, even the highest quality/lowest compression setting available still uses this algorithm, resulting in a minimal lossy compression and loss of information.

You should also note that with relatively high quality levels, the file size quickly shrinks if you reduce them slightly while there is nearly no notable difference. In contrast, a slight change in the range of low quality levels is well visible and only has a low impact on the file size.

If you want to absolutely avoid any information loss, you should work with photos in a lossless format (e.g. RAW or lossless TIFF) and only convert them to a format with lossy compression once in the end if you want smaller file sizes, don't repeatedly save in a lossy format.

\$\endgroup\$
2
  • 15
    \$\begingroup\$ PNG is also a lossless format and is commonly used to store images in. It is also supported by greater number of websites (basically, any) than RAW or TIFF. \$\endgroup\$
    – altskop
    Nov 20, 2017 at 5:50
  • 1
    \$\begingroup\$ @altskop: You're comparing apples to oranges. A RAW file includes much more information than a corresponding PNG and is also smaller. \$\endgroup\$ Nov 20, 2017 at 19:40
14
\$\begingroup\$

To simplify a bit, JPEG image compression splits the image into different frequency components and stores them separately. Depending on the compression settings, it also stores the higher frequency components with less precision, since any round-off errors in those components are less visible to the human eye. After rounding off the data, it then applies a simple variable-length encoding where smaller numbers take less space — in particular, if a lot of the higher frequency components round off to zero, they can be encoded very compactly.

What all that means is that the less high-frequency detail your image has, the smaller it becomes when JPEG compressed. So if your images are systematically getting smaller after you edit them, that can be due to a couple of different things:

  1. You're saving them with a lower quality setting.
  2. You're removing some of the high-frequency components of your images while editing them, e.g. because you're denoising them. The less noise an image has, the less space it takes up in JPEG format.
  3. You're applying chroma subsampling when saving the edited images, whereas the originals were saved without it. Chroma subsampling is a feature of the JPEG format that basically splits the image into a grayscale version, which is stored at full resolution, and the color saturation and hue, which are only stored at half resolution. Since the human eye is pretty insensitive to high-frequency color detail, this is a good way to save space, but it can sometimes cause noticeable "color bleeding" e.g. if the original image contains small brightly colored spots.
  4. The original image files had some large metadata blocks (such as an attached color profile) that got dropped when you resaved them. (This shouldn't account for an 8-9 MB size loss, though.)
  5. You're actually scaling the images to a smaller pixel size / lower resolution while editing them. (Just including this for completeness.)

If your images are getting smaller after editing simply because you're removing useless and unwanted noise from them, then everything's fine. To rule out the other possibilities, you may want to take a look at your JPEG export settings in GIMP:

GIMP JPEG Export dialog

  1. To make sure you're re-saving the images with the exact same quality as before, select the "Use quality settings from original image" checkbox in the JPEG export dialog (under "Advanced Options"). This will also minimize any incremental quality loss from repeatedly decompressing and recompressing the image (although, due to creeping round-off errors, it can't entirely eliminate it).
  2. To make sure you're not blurring the images when saving them, check that the "Smoothing" slider is at zero.
  3. To rule out color subsampling, explicitly select "4:4:4 (best quality)" from the subsampling options. (Actually, checking the "Use quality settings from original image" box should also automatically set the subsampling to whatever setting the original image used. If you've only edited the image slightly, this can actually give better results than changing to 4:4:4.)
  4. To preserve the metadata from the original image, select the "Save EXIF data" and "Save XMP data" checkboxes if they're available (i.e. not grayed out).

(The "Optimize" and "Progressive" settings in the dialog can also change the file size a bit, even though they don't affect the image quality in any way, since they adjust the non-lossy parts of the JPEG compression algorithm. Their effect is typically a few percent at most, though. Including "restart markers" in your image file will also increase its size slighty; normally there's no point in using them. And, of course, including a thumbnail in the image file will also increase its size by a few kB. The "DCT method" is an obscure setting that basically controls the way the rounding and frequency component separation calculations are done: it does have a slight but noticeable effect on both image quality and size, but it can go either way. If you're not sure what you're doing, just leave it alone.)

\$\endgroup\$
6
  • \$\begingroup\$ this answer seems overly technical, someone who asks if JPEGs of certain size are good enough will likely not benefit from it. "to simplify [...] JPEG splits image into frequency components" might be a good joke in this context but is not helpful at all. \$\endgroup\$
    – szulat
    Nov 20, 2017 at 22:21
  • 1
    \$\begingroup\$ @szulat: You may be right. I don't see how to make it less technical and still explain the possible reasons for the size reduction, and in particular why denoising matters, though. All a casual user really needs to understand about JPEG compression is that it makes the images smaller but uglier, but that level of understanding doesn't really answer the OP's question. (Note that the OP is not asking whether "JPEGs of certain size are good enough"; they're asking why their images are getting a lot smaller even though they're saving them at high quality.) \$\endgroup\$ Nov 20, 2017 at 22:51
  • \$\begingroup\$ Actually, Ilmari Karonen was very helpful by showing me what to do within the GIMP program re: settings for saving. Frequency components and round-off errors does lose me but the image works well. I gained a bit from each response. I will try checking the settings in GIMP. I don't know if it will let me save the original JPG as a PNG but I will also try that. I thought someone told me that it was the megapixels that mattered more than the file size. When I compare the large to a small I see no difference from pixel to pixel. I'll see if I can post. \$\endgroup\$
    – LittleLex
    Nov 21, 2017 at 23:48
  • \$\begingroup\$ I don't see that I can post a pic. I saved the 11MB pic as a .PNG and it is now a 20MB file. So I am understanding if I keep it as a .PNG it won't lose bits and pieces every time it is saved? (And that maybe it might not matter for my purposes) I'll edit a few and save them then order some prints to see how they look. The GIMP settings for saving the .PNG have compression at 9 (default settings). Any advice on those settings? I've read and tried to learn some of this stuff--it is like acid/base--I'll never grasp it! \$\endgroup\$
    – LittleLex
    Nov 22, 2017 at 0:20
  • \$\begingroup\$ Yes, PNG is lossless, but almost always produces bigger files (for photos; simple drawings are another matter) than JPEG. The PNG compression level setting has no effect on image quality at all -- bigger values just make the file (usually) a bit smaller and make saving it take slightly longer (but even that's not really noticeable on a modern computer) because the code is spending more time on trying the find the most compact way to store the image data. \$\endgroup\$ Nov 22, 2017 at 0:50

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.