Tuesday, 19 May 2009

A photographer's practical guide to jpeg

Stemming from the question on the last post about sizes of pdf books, I thought it was worth writing about JPEG images: sizes, resolutions, compression etc. This is based on a little technical reading and a lot of practical experimentation. Technically, I may be a little off in some areas but this will be good enough for the masses.

The aim of a JPEG image is to preserve as much detail as possible while compressing the file size as much as possible. By setting the quality/compression (these 2 are the reverse of one another - high compression gives low quality) value you are determining the trade-off between quality and file size. However,there is a general misconception as to how this works.

For highly detailed images (think lots of tree branches and small leaves) there is automatically less compression as the JPEG tries to keep the detail. If your image is highly detailed then you can actually use lower quality setting and still get an excellent image. In the other direction, large expanses of nothing compress very well. If you shoot a picture of a white wall even the highest quality setting will give a small file. JPEG is clever like that. The tricky stuff comes when there is a mixture of detail and even tones (e.g. trees against a blue sky). The even part compresses well, the detail is kept in the main but at the edges JPEG gets confused, throwing up those nasty artefacts. This is where judicious use of the quality level is needed. I'll come onto advice on values later.

The next part is the resolution or pixel size of an image. If you are printing, you'll want high quality files with lots of pixels. Typically 240-300ppi for the given print size. That means the total pixel size will be the paper size multiplied by 240 or 300 (e.g. if I print a 10"x8" at 300ppi, that'll be 3000x2400 pixels). Nice and easy.
The tricky part is on-screen display. To display on the majority of monitors, you only need an image about 1000pixels wide or 600 pixels tall. Maybe a bit more to cover larger displays. If your software works as a size & resolution then the size multiplied by resolution shouldn't be more than about 1000x600pixels (e.g. if I have a 10"x8" page for on-screen display, I need a resolution of only 100ppi to give 1000x800pixels). This is important for pdf generation, as pdf is designed to work in physical size and resolution. To cover most monitors today, you don't need more than 100ppi resolution (nor page size more than about 12"x8").

So what about recommendations for compression values? JPEG generation generally has one of three ways of setting quality: a high/medium/low scale; a JPEG compression factor (typically a number up to 100) or another numerical scle of some sort (e.g. Photoshop's 1-12).

For printing, go high. Photoshop 9 or 10 (11 and 12 really are pointless and don't practically give better results), JPEG factor 90 or 95. NOTE: JPEG compression factors are NOT percentages. the maximum value (from the JPEG standard) is 95 - any scale that goes to 100 is distracting you.

For on-screen display, you only need a medium level. Photoshop 7 or 8 (sometimes lower but go careful); JPEG factor 70-75. This will yield a files size about half that of the higher qualities and still give excellent on-screen display. Use the lower values unless there is a big mix of detail and even tones.

A final note on setting resolution versus compression, especially in pdf generation. The biggest win in file size (small being good) is a lower resolution. 300ppi has 9 times the pixels of 100ppi. To get that kind of compression with quality you need to go down to about 20-25 quality factor, which is barely recognisable. You could probably go down to 90ppi and give good display quality even on large monitors (a factor 11 smaller than 300ppi).

As for pdf books for the web (aimed squarely at the SoFoBoMo crowd) - aim for file size that gives around 50-60kB per page or 100-150kB per image overall (non-image pages generally take very little space in pdf). If you've gt 40 images in 55 pages (typical SoFoBoMo fare), that's 2.7-5.8MB total filesize.


  1. Thank you so much. I asked this question on the flickr site when I first signed up and didn't get an answer. I had about come to some of these conclusions myself but was afraid to drop quality as much as you have suggested. This is a big help to me.

  2. Thank you for the extrememly useful tutorial. Although I somehow managed last year to get my file to the recommended size (lots of reading and considerable frustration with trial and error), I look forward to taking this on this year armed with more information. Your generosity is appreciated.

  3. OK... I plead a little bit guilty about being conservative with compression. I used a JPEG “quality” factor of 80 from Lightroom (scale 0 to 100). I get a little picky about compression artifacts. Back in the day I’d use ImageReady to compare minute differences between 65 and 70 and 80 and so on. But since I was processing so many images, I didn’t want to fuss with that. 80 is my standard “good enough for 4 by 6s” level, so it’s safe for all on-screen images. I *could* have been more aggressive with compression, but I really didn’t think had a reason to. I was well under the size limit for Issuu. Why skate too close to the edge?

    My images are sized appropriately for my e-book – they’re 900 x 600 pixels at 100 dpi. With a quality factor of 80 they vary from around 100KB to 400KB in size. I’m not sure what causes the huge variance; I suspect it has to do with a lot of the fine detail, even in that small number of pixels. It would actually be interesting to plot the numbers, as the distribution appears fairly even except towards the ends.

  4. This free sharing of knowledge makes the whole SoFoBoMo experience even more rewarding. Thanks a ton!

  5. Thanks for the information. I way overdid it as I used up 13MB for only 37 images and the text for the other 40 pages. Now, if the book was to go for printing would one keep the larger ppi?


  6. Amy - sure that's within their storage limits but I'm always pushing for smallest files with acceptable quality. The size spread will be due to detail. File sizes for images like that are a bit big IMO for online. Don't forget, people viewing it have to download all that and not all connections are fast.

    Robert, definitely I produce a high quality, high res file for printing. Even the proof sheets have a 300ppi version for me to use as prints. That means 2 copies of my books, too. Whereas the online versions of my books are 4-5MB, the print files for the same are 30-40MB.


I like comments, especially constructive ones.
Comments get emailed directly to me before publishing , so if you want to get in touch drop a comment.
All comments moderated by me before being published, keeps the spam at bay.