Alley in Pisa, Italy

by Lars Kotthoff

submit your photo


Hall of Fame
View past winners from this year

Please participate in Meta
and help us grow.

Take the 2-minute tour ×
Photography Stack Exchange is a question and answer site for professional, enthusiast and amateur photographers. It's 100% free, no registration required.

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.

share|improve this question
    
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? –  Reid Dec 7 '12 at 18:22

6 Answers 6

up vote 6 down vote accepted

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 excellent visual resource for how JPEG compression affects IQ can be found here:

An Analysis of Lightroom JPEG Export Quality Settings

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.

share|improve this answer
    
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. –  santiagozky Dec 7 '12 at 14:45

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.

share|improve this answer
1  
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? –  chills42 Dec 5 '12 at 17:07
    
@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. –  Matt Grum Dec 7 '12 at 9:12

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).

share|improve this answer
    
"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). –  Matt Grum Dec 5 '12 at 14:29
    
@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. –  Olin Lathrop Dec 5 '12 at 15:12
    
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.) –  Michael Kjörling Dec 7 '12 at 14:53
    
@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. –  Olin Lathrop Dec 7 '12 at 22:00
    
I know about Bayer matricies, and their use in digital color photography. My point was that if the raw file contains 14 bits per pixel, then a 24-bit-per-pixel JPEG or TIFF would be able to capture all of that information since it would expand the available color space - and even without knowing what camera you use, I feel it's a fairly safe bet that it doesn't. And I have ~18 MiB 4770×3177px raw files from a 14-bit-ADC camera, which would require at least ~25.3 MiB to store uncompressed (4770 × 3177 × 14/8). 30% savings is within the ballpark for some form of lossless compression. –  Michael Kjörling Dec 8 '12 at 0:02

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.
share|improve this answer
    
Very subjective. I can easily see any compression below 85, so that is what I use for web use. For print, 96 at least. –  Itai Dec 5 '12 at 15:24
    
@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. –  Guffa Dec 5 '12 at 15:50
    
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. –  Itai Dec 5 '12 at 15:54
    
if your website will repack it anyway you should upload a source file of Quality 90-100%. –  Michael Nielsen Dec 5 '12 at 16:02
    
@Itai: You seem to be contradicting yourself. Using a high quality level will increase the file size, which makes the website slow. –  Guffa Dec 5 '12 at 18:29

Use 90, or preferably 95. In my experience, the size gain when using anything under 90 is in most cases no longer beneficial with regards to 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.

share|improve this answer
    
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. –  jrista Dec 6 '12 at 18:37
    
Quality is different in different software; can you add some of that context to your answer? –  Reid Dec 7 '12 at 18:23

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

share|improve this answer
    
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. –  jrista Dec 6 '12 at 18:39
1  
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. –  Michael Nielsen Dec 6 '12 at 18:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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