54
\$\begingroup\$

When you export a picture to JPG you can normally choose its quality in a 1-100 scale. I like to keep a good quality but it wouldn't make sense to keep a JPG that will be almost as big as the original RAW, so is there any guideline to select a particular JPG quality for particular uses? I am mostly interested in Internet sharing and ordering prints online.

\$\endgroup\$
2
  • \$\begingroup\$ This depends on the software you're using (e.g., the Lightroom recommendations in jrista's answer aren't the same in other apps); what is your workflow? \$\endgroup\$
    – Reid
    Commented Dec 7, 2012 at 18:22
  • 1
    \$\begingroup\$ "... keep a JPG that will be almost as big as the original RAW ..." +1 for Olin's answer that shows that even a 100% JPEG can/should be noticeable smaller that RAW. \$\endgroup\$
    – Martin
    Commented Nov 1, 2014 at 22:34

9 Answers 9

49
\$\begingroup\$

To be frank, it is entirely anecdotal that a JPEG image should be exported at a certain compression level all the time. The amount of JPEG compression should really depend on the usage purpose for the JPEG, and the contents of the JPEG.

The quality level one should choose when exporting an image to JPEG is highly dependent upon the kind of detail contained within the image. An image of a smooth blue sky or a sunset sky with large areas of orange gradient should probably use a high quality setting, 90-100. An image that contains nothing but complex detail could probably get away with a quality setting of 50-60, possibly even lower. There is no single "best" JPEG compression setting, and depending on the type and complexity of detail (or lack of complexity and detail), you may find yourself using 40-60, 70-80, or 90-100 as appropriate for the photo(s) you are exporting.

An Analysis of Lightroom JPEG Export Quality Settings is an excellent visual resource for how JPEG compression affects IQ.

This site demonstrates JPEG compression from the lowest to highest settings in discrete ranges for a series of sample images of differing content. You can clearly see, by observing each image at each compression level, why a higher setting such as 90-100 may be required in some cases, and a lower setting such as 40-60 is entirely acceptable for others.

As a side note, if you are saving a JPEG for any kind of print purpose, or for viewing on-screen at a large size (i.e. as a wallpaper for a 30" 2560x1600 screen), there is no reason not to use the best quality setting available. When saving for web, compress as much as you can without introducing visible compression artifacts. Different classes of images will regularly fall into certain JPEG compression levels (the site linked above can help learning what fall where)...so it can quickly become second nature to know what compression level to use when saving various images for the web.

\$\endgroup\$
5
  • 2
    \$\begingroup\$ I was not aware of how jpg compression works. your answer (and the link) provided an good insight. Before I thought that pictures with more detail would require more quality. your answer was very helpful. \$\endgroup\$ Commented Dec 7, 2012 at 14:45
  • 1
    \$\begingroup\$ File sizes being equal, it's also better to use a high resolution high compression photo than a low resolution, low compression photo. \$\endgroup\$ Commented Aug 1, 2022 at 22:50
  • \$\begingroup\$ In Gimp, what subsampling should you use? \$\endgroup\$ Commented Aug 1, 2022 at 23:24
  • \$\begingroup\$ @KevinWheeler if you're looking at image detail down to the pixel, you should use no subsampling at all. It can really damage the image particularly in areas of red. Unfortunately I'm not familiar with Gimp specifically so I can't give guidance there. \$\endgroup\$ Commented Nov 12, 2023 at 14:40
  • \$\begingroup\$ In most of those examples, I would go with Q ∈ [53, 61] on a budget, and Q ∈ [69, 76] for a bit more quality without file size blowing up. The discoloration, loss of sharpness, and other artifacts are still visible to a careful eye for the detailed/high-frequency images -- particularly if compared with the original reference image. For no-reference quality, I guess it's a bit more debatable. \$\endgroup\$ Commented Jul 29 at 20:39
9
\$\begingroup\$

Disks are still pretty cheap these days so there are advantages to JPEG files, even if they are as big as the original RAW, instant image preview, being able to display on computers without RAW software.

The "quality" parameter determines the quantization matrix used to compress the data. Without going into too much detail this determines the degree to which the frequencies contained in an image are approximated to achieve compression. The important thing to note is that there is no direct correspondence between "quality" and final size.

Therefore quality merely determines what proportion of image information will be lost, if an image that contains more information to begin with (in terms of high frequency details) you will get a larger JPEG file even with the same quality settings. There is therefore no global setting you can use, if you want files of a certain size you have to tune the quality for each image.

Alternatively you might want to use a higher setting for images with more fine detail (or noise - noise doesn't compress well so can result in more artifacts). If you are doing a one off image I would use any program that gave you a preview of the compressed image (Photoshop does this) and play with the value until you get the quality you want at a size that is reasonable.

I never archive in JPEG format, I always keep the original RAWs, so any time I'm producing a JPEG it is for display on screen. I used to start with quality 7 (out of 12) in Photoshop, unless I noticed artifacts, then I would increase it. Then I moved to 9/12 as my default quality. As internet connections speeds and storage increased much faster than screen resolutions, these days I just use 11 (one step down from maximum, there's a bit of a jump in size when you select 12) all the time and don't worry about it.

When sending images to print, if they have to be JPEGs I use the highest quality I can unless the print company complains. You've worked hard on an image, there's no sense reducing the quality to cut upload times by a few minutes.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ I'm not sure what exactly you mean by this "Disks are still pretty cheap these days so there are advantages to JPEG files..." It looks as if there may have been a typo? \$\endgroup\$
    – chills42
    Commented Dec 5, 2012 at 17:07
  • \$\begingroup\$ @chills42 No typo, the questioner asked whether it made sense to keep a high quality JPEG, even if it was almost as big as the RAW file. If you were concerned for disk space you should keep only the RAW and generate a high quality JPEG whenever you need one (to print etc.) but since disk space is less of an issue these days I think there are advantages to JPEG + RAW as an archival format. \$\endgroup\$
    – Matt Grum
    Commented Dec 7, 2012 at 9:12
7
\$\begingroup\$

I keep my jpeg quality slider at 100% for my "developments", and will so I lose less detail before the online site will recompress it anyway. If I put it on my own site through ftp I might choose 90% and supply a thumbnail. 80% of online people watching photos online has a fast DSL anyway.

Here is a test with quality from left to right: 10,20,30,40,55,70,80,90,100% I show crops from each file.

File sizes for the full files are: 210k, 278k, 347k, 477k, 601k, 709k, 987k, 1.7M, 7M.

The raw file was 8M but remember that is basically a monochrome image and a smaller thumbnail plus a little meta data. The BMP is 30.5Mb!

To me the difference from 100 to 90 is noticeable but very small. But I would never go under 100% if there is a chance I might want to open it and process it further. below 100% is a "process time EVER" deal.

From 90 to 80 the difference is bigger, and 70% starts to look like crap. So my conclusion is: for backup and possible reopening 100% if you need to save some space/upload/DL time and it wont get repacked: 80-90%.

Jpeg test

Look at the detail differences in the BMP File

\$\endgroup\$
2
  • \$\begingroup\$ Any chance you could do this with images of different types? The only reason 70% starts (I wouldn't say it looks like crap) to exhibit a loss in IQ is because of the background sky gradient...which are the worst kinds of regions for jpeg-style lossy compression. Images that contain complex detail and little or no smooth surfaces can be compressed to a much higher degree and still appear perfectly acceptable. \$\endgroup\$
    – jrista
    Commented Dec 6, 2012 at 18:39
  • 1
    \$\begingroup\$ but the image crop contains the two extremes , so you can evaluate the loss on the gradient as well as the straws. And to me even the grass patches look degraded at the 70%. And why accept any disturbing artifacts in a world where you don't ever need to save 100kb? Well... maybe if you make a cellphone website specifically for people who are roaming abroad. But even then you gain more by reducing the resolution. \$\endgroup\$ Commented Dec 6, 2012 at 18:43
7
\$\begingroup\$

Use 90, or preferably 95. In my experience, the size gain when using anything under 90 is in most cases no longer beneficial in relation to perceivable quality loss, and should only be used on very specific images that can profit from JPEG compression and/or need to stay under a maximum file size (e.g. images used when building a website).

JPEG compression lower than about 75 will definitely show visible artifacts.

\$\endgroup\$
3
  • 2
    \$\begingroup\$ This really kind of depends on the image contents. I'd agree that, if there are significant smooth gradients or flat surfaces, 90 is probably the limit. However in images full of complex detail, one can get away with much less than 90...as low as 75 or perhaps lower, without readily observable losses in IQ. \$\endgroup\$
    – jrista
    Commented Dec 6, 2012 at 18:37
  • \$\begingroup\$ Quality is different in different software; can you add some of that context to your answer? \$\endgroup\$
    – Reid
    Commented Dec 7, 2012 at 18:23
  • \$\begingroup\$ @OlafM: indeed there wouldn't. And there wouldn't be a question either. That's why I specifically mentioned: 'in my experience'; it's a subjective question. \$\endgroup\$
    – pleinolijf
    Commented Oct 27, 2015 at 12:37
2
\$\begingroup\$

To get the best possible compromise between compression and quality you would have to try each image with different compressions to see where the quality is acceptable. If you don't want to do that to every image, you can try out a few images and then go with that compression level, and accept that the level is close enough.

As a starting point:

  • quality 60: good for web
  • quality 80: good for online printing

What to look for, to spot JPEG compression artifacts:

  • Every 2x2 pixel block share the same color hue, so along very sharp borders between contrasting colors you may get colors bleeding through the border.
  • The compression is based on 8x8 blocks of gradients, so at lower compression you see the blocks starting to emerge.
  • Where a sharp contrast appears close to a smooth area, for example a tree line against the sky, the compression is most visible, in the form of crincles in the smooth area.
\$\endgroup\$
7
  • \$\begingroup\$ Very subjective. I can easily see any compression below 85, so that is what I use for web use. For print, 96 at least. \$\endgroup\$
    – Itai
    Commented Dec 5, 2012 at 15:24
  • \$\begingroup\$ @Itai: If you don't want the compression to be visible in any way, then you shouldn't use JPEG compression in the first place. Even at level 100 you still have compression artifacts. \$\endgroup\$
    – Guffa
    Commented Dec 5, 2012 at 15:50
  • \$\begingroup\$ At 100, they are measurable but negligible. I cannot see them at 96 and above without scrutinizing the photo. For web use, it is really needed, otherwise images get too heavy and websites get slow. \$\endgroup\$
    – Itai
    Commented Dec 5, 2012 at 15:54
  • \$\begingroup\$ if your website will repack it anyway you should upload a source file of Quality 90-100%. \$\endgroup\$ Commented Dec 5, 2012 at 16:02
  • \$\begingroup\$ @Itai: You seem to be contradicting yourself. Using a high quality level will increase the file size, which makes the website slow. \$\endgroup\$
    – Guffa
    Commented Dec 5, 2012 at 18:29
2
\$\begingroup\$

What Matt said, but I want to add that JPEG actually has two compression schemes built in. The first is based on a discrete cosine, which allows certain frequency components of the image to be thrown out. This is the lossy compression with the "quality" parameter that can trade off compression with fidelity. At maximum quality, this compression scheme is mostly eliminated.

JPEG also uses huffman encoding for additional compression. That is a lossless scheme, so it is always there without any need to control it.

So even at maximum "quality", JPEG will have some useful compression. I just looked at sizes of one example image of a ordinary scene for comparison. The Nikon NEF raw file is 26 Mb, which contains 14 bits/pixel and is uncompressed. My post-processed JPEG version saved at maximum quality is 9.1 Mb. This contains 24 bits/pixel, although of course some information is lost and other information interpolated from values in the original raw image. This same post-processed image converted to a TIFF file with LZW and forward differencing compression (both lossless) resulted in 20.3 Mb.

As a final experiment, I copied the 9.1 Mb post-processed file and the TIFF file resulting from it both to JPEG files with maximum quality setting. Both resulting JPEG files are exactly the same size to the byte of about 8.5 Mb. This shows that even at maximum quality, just a little lossy compression is going on, but not much. It also proves the point that no information was lost at all going to the TIFF file.

As Matt does, I archive the original RAW files from the camera. I also archive my general purpose post-processed version as JPEG with maximum quality. Even pixel peeping at high contrast and sharp edges doesn't reveal compression artifacts to the human eyeball. I like having the post-processed picture in JPEG form because its probably the most immediately usable format. If there is a issue and I want something different, I've always got the raw file to re-derive a another post-processed version from with different tradeoffs.

I used to use 80 as the default quality level of my JPEG images (my software has 0-100 for its quality range), but lately I've been using 100 as default unless there is a specific need for a smaller file size. There usually isn't. I have gone so far as changing the default for the JPG image driver in the source code so that I don't have to keep specifying the quality level most of the time. It's not like the old days where a Gb was a lot of memory. (Actually, I'm old enough to remember when 1 Mb was a decent amount of disk space, but back then we weren't doing digital photography either).

\$\endgroup\$
8
  • 4
    \$\begingroup\$ "discrete cosine" is not in itself a form of compression, it's an transformation into frequency space. In JPEG the frequency coefficients then undergo quantization (integer division) which zeros some of them out, before lossless compression with run length encoding and then Huffman encoding. The point is the discrete cosine transform itself is lossless, all losses occur during quantization. When setting quality to maximum, quantization is effectively only rounding the coefficients (which are real numbers) from the DCT, however data is still being lost (albeit pretty much invisibly). \$\endgroup\$
    – Matt Grum
    Commented Dec 5, 2012 at 14:29
  • \$\begingroup\$ @Matt: Yeah, you got me. I was being sloppy with the math and have reworded the statement. I'm actually impressed there is enough technical vigillance here on the photography site to catch that. I don't usually run into photographers that paid attention in signal processing class, if they ever attended one in the first place. My bad. \$\endgroup\$ Commented Dec 5, 2012 at 15:12
  • \$\begingroup\$ I'm pretty sure the raw file doesn't contain 14 bits/pixel. If it did, going to eight-bits-per-channel RGB (24 bits/pixel) would add possible color fidelity, and RAW would lose its biggest advantage. It might however contain 14 bits of data per photoreceptor. It is also likely losslessly compressed. (This is easily verifiable by looking at the file sizes of various shots: if they aren't very near the same, there is some level of compression involved. The raw files from my EOS 50D can easily vary between ~18 and ~25 MB, indicating that compression is done.) \$\endgroup\$
    – user
    Commented Dec 7, 2012 at 14:53
  • \$\begingroup\$ @Michael: I don't see how you can be so sure about my RAW file when you don't know what settings I use or even what camera they are from. The image data in these raw files is uncompressed and contains the 14 bit sensor information for each pixel. There is only one color at each pixel. Look up something called a "Bayer matrix". The 14 bit pixel data is actually stored as 16 bit words, so the 4288 x 2844 image is stored in 24.4 Mbytes. These files contain other variable-length information, and are usually close to 26 Mbyte in size. \$\endgroup\$ Commented Dec 7, 2012 at 22:00
  • 1
    \$\begingroup\$ @Michael: Yes, a 8 bit/color/pixel image has more bits per pixel than a 14 bit raw file from a Bayer matrix. However, having more bits does not mean more information. You can take a 8 bit ASCII text file and store it as unicode, but that doesn't add information although it takes twice the space. In a sense with a 8 bit/color/pixel image you are paying for convenience with space. Good compression schemes can reduce the file size closer to its real information content, so we can get the 24 bit image "cheaper" by doing compression and decompression at each use. Everything is a tradeoff. \$\endgroup\$ Commented Dec 8, 2012 at 12:57
1
\$\begingroup\$

It's often more efficient to reduce the size of the image than the quality, especially if you only want to use for internet sharing. Also you might have various strategies depending on the status of your image. I store my own photos in photos.app with 100% quality for the best, 80% for the good and 50% for the rest

\$\endgroup\$
0
\$\begingroup\$

Anything you have any special love for, or think you will at one point use commercially you should keep as a DNG or other RAW format file. All casual photography you do, you shoot RAW and do your post on the RAW, then you save it as 80% JPEGs.

\$\endgroup\$
-1
\$\begingroup\$

..save at 100% because you can't go back if saved lower but you can go down if saved higher..drives are cheap and computer's are powerful.

\$\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.