|
Troubleshooting Photos –
About JPEG
Snapshot: JPEG (.jpg) is the preferred
photo format for pros and amateurs for lots of good
reasons (you'll find brief info on other photo formats here),
but it does have limitations that you can easily avoid.
This article begins with a general discussion of the format, where it came from and why it works as it does, then goes on to discuss:
Some attempt has been made to make each section stand alone, but this can't be done entirely without making them repetitive.
JPEG is a picture file format – international, cross-platform and
managed by the International Standards Organization (ISO). JPEG (say 'jay-peg')
stands for Joint Photographic Experts Group, photo and publishing
industry people who defined the format.
JPEG was launched in the early 1990's to speed images over the networks
that preceded the Internet, mostly for large commercial printers and newspapers.
All the file formats then in use made big files, so sending times were
excessive. JPEG yielded files between 1/20th and 1/100th the size, which
helped enable our present image-rich Web. What we now use in cameras is
an extension of the original format that allows smoother interchange between
the camera, the web and computers, plus the addition of
EXIF information.
JPEG files are much smaller than files in older formats like TIFF
because the JPEG experts changed the way the image is presented.
Early digital photo formats treated every pixel as being equally important,
whether in the highlight (bright areas), middletones or shadows. A 640
x 480 pixel TIFF will always be about 900 Kb, no matter what's in it. File
compression shrinks TIFFs in a rather linear fashion, usually
little more than about 50%, so that 900 Kb file could be shrunk only to
about 500 Kb – a monster given the network speeds available 20 years
ago. Accordingly, JPEG was built with the goal of achieving 'good-enough'
pictures at the smallest possible size, so by its nature a JPEG varies
in size according to how much of the picture info is significant. Also,
JPEG permits the user to set a compression level. The result is that
where the 640 x 480 TIFF will be 900 Kb uncompressed, a usable
JPEG may come in between 1/20th and 1/100th of that size, depending on
the level of compression – which may
be called a 'quality' setting – set by the user.
JPEG’s compressor is variable because while every photo needs to
be good enough to do its assigned job, most photos don't need to be artistic
masterpieces – they just need to show an object or occurrence in
general terms. Think of your own photography – for some scenes, you
want a carefully composed shot that's the best you can get; for others,
you'd be happy with an off-the-cuff snapshot. Similarly, JPEG's authors
understood that some pictures need to be absolutely faithful to the original,
while others need only give information. Accordingly, the JPEG compressor
can be set to save a file that preserves every nuance of the original photo
(what most programs call 'high quality'), a very small file that has lost
much of its fine detail ('low quality'), or something in between. In most
publishing, lower quality settings are the norm because publishers know
you're only going to glance at a photo before turning the page. The exceptions
are magazines that people examine closely, such as National Geographic,
quality fashion and car magazines and – surprise – Playboy.
The trade-off is that while older file formats and compression schemes
allowed you to compress and decompress an image without loss of information
(so these are referred to as lossless,
JPEG compression discards some picture data. This is no problem as long
as you understand what you're doing.
JPEG's compressor achieves its results by playing off a few facts about
human vision and the way we use pictures.
- People generally are interested in an overall impression of a picture, not its details.
- Detail in shadows is low priority because people don't pay attention to it.
- Your eyes are more sensitive to luminance (light levels) than they are to color, so most photos
carry far more information – and certainly more information about fine gradations of color
– than many people care about, or are even able to see.
- As long as the interest area (the subject – typically the light-
to middle-toned area of the picture) – is reasonably lifelike, people
will accept the whole picture as lifelike.
- Many pictures don't need to be very detailed or very finely colored,
because
they're just for information, not beauty, and won't be looked at closely –
these can have maximum compression applied to save disk space and network
time.
Three pictures, three intended uses. The first picture, beauty, is intended to show you
all the beauty of a rose. The colors are rich and the details are subtle – look at the
delicate veining in the petals, particularly in the upper right edges. Now look at info 1,
where the veining has been replaced by some distracting artifacts where the yellow meets the
background. This is the same photo, but it was saved at a 10 or 'low' quality setting instead
of the 60 or 'high' setting used for beauty.
Now, on screen the differences between the two roses are subtle to most people, but that's mainly because
screen resolution is relatively coarse. When you print the two files, typically at three times screen
resolution, the loss of detail and the growth of artifacts jump out at you. So why choose either one?
If you're printing the photo, Beauty lets a viewer experience everything but the smell.
Info 1 tells you that the flower is a rose and that it's yellow.
If you are 1) emailing the photo to a friend or 2) printing a catalog
with hundreds of images, you'll appreciate
info 1 being 1/3 the size of beauty. Similarly, if you're like the heating contractor
who took info 2, you'll appreciate the compact, 13 Kb size of this picture of a boiler. It's
not pretty – there are lots of artifacts and there's a distinctly fuzzy quality to it – but
it shows where the pipes run which is all he needs, and at 1/3 the size of a high-quality photo, it
doesn't strain his creaky customer database the way hundreds of better quality but larger files would.
The JPEG compressor performs a number of steps that reduce the file size
(and the image quality) according to the compression
setting you choose. First it
analyzes the entire picture for its color and tone content, then reduces
the number of colors, discarding subtle differences, particularly in the
darker areas. Slight variations of a color thus become a single color.
The compressor then creates 8x8 tiles of pixels and writes an economical
description of them. Lossy activities, like simplifying the color palette
and tonal variations are performed subtly or aggressively according to
your compression setting. The more aggressive the simplification,
the smaller will be the resulting file.
JPEG is excellent for gradual transitions of color but well defined edges
can be a problem. Where clear divisions occur, you may see compression
artifacts,
particularly at high compression levels. The picture above shows five
300% enlargements of the view-camera icon used on this site. The left
icon is a GIF (or .gif – handles edges and single-color
areas well, but is useless for photos, because it causes banding).
The second, third and fourth icons are variously compressed JPEGs (3,
30 and 60 on a scale of 0-100 where 3 is highly compressed and therefore "low" quality).
Note the artifacts – blocks of gray in the black and in the white
areas. Admittedly, this is a worst-case situation that won't be an
issue in most photos, but note that this can happen and you should
adjust compression levels accordingly. Watch out for this effect in
edge areas like people's noses (especially when they are crisply defined
in profile), hair and clothing details. The solution within JPEG is
to use a high-quality, low-compression setting for a photo; for a combination
of photo and text, as above, the preferred solution is the
PNG format
(which was used for the assembled image). PNG makes largish files but
does edges well and doesn't yield artifacts.
JPEG and the Camera
When you click the shutter on a digital camera, the captured image data streams into the camera's processor where:
- It's translated from 12-bit to 8-bit data.
- White balance
is either set automatically or according to a setting you made.
- A color profile
is set automatically or according to a setting you made.
- A tone curve is applied, which means the light and middle tones that interest the human
eye are reproduced faithfully while shadows are de-emphasized.
- The edges of objects or changes in tone may be emphasized
(sharpened), if you have set the camera to do this (and you shouldn't – do
it in your editing application after you've decided if it needs it).
- The camera will take notes on its own settings – everything from f-stop and flash
settings to what sort of light metering was used – and add them to the file as
EXIF data.
- The main event is compressing the image file according to your earlier
choices (see above for what's actually done). Typically cameras offer
a 3 x 3 matrix of options – 3 sets of dimensions with names like
basic (an example from one camera: 1504 pixels x 1000 pixels), medium
(2256 pixels x 1496) and large (3008 pixels x 2000) alongside three levels
of compression for each size, which typically are described as high quality
(larger file), medium quality and low quality (smaller file).
Some cameras offer an additional file type, RAW.
JPEG is a better choice for most amateur photography – and a lot of pro work – because:
- JPEG files are much smaller;
- your camera probably can write a photo to memory and be ready to shoot
again more quickly with JPEG than with RAW;
- JPEGs normally require much less processing on the computer to view
and print; and
- RAW file formats are specific to each manufacturer and so may not be ideal for long-term storage.
This section will tell you more about file formats,
including RAW.
Working With JPEG
Before digital cameras adopted the JPEG as their standard, JPEG was considered
purely a 'destination' format, which means that you were supposed to work
on a picture as a TIFF or some other format that saved losslessly,
then convert it to JPEG as a final step. Editing JPEGs was simply not done
because re-saved JPEGs developed artifacts (see
also examples as Disasters)
very quickly. The editing routines are much better now, but there is still
a consensus that JPEGs shouldn't be edited and re-saved more than absolutely
necessary.
The recommended process of handling photos (the 'workflow') from pressing the shutter button to finished photo goes like this:
- Shoot your pictures, using the highest quality and pixel dimensions
available unless there are compelling reasons to use a smaller image
or a lower quality setting (memory is cheap and getting cheaper – see
About Buying Photo Equipment).
- Copy the photo files from the camera to their own folder on your computer.
Give the folder a meaningful name. Don't even look at them yet – immediately
copy the new folder, and either leave it as "Meaningful name copy" or "Meaningful
name originals". Don't touch this folder – these copies are your
insurance in case you mess up a picture from the first set of photo files – in
which case, you make a new copy of the photo from the second folder.
- If the photos are important to you, immediately burn a CD-R or DVD-R
of your untouched photos.
- Now you can look at your new photos. Use a catalog/viewing application or the image browser
of your editing application. Identify the images you'd like to edit and divide them into two groups:
minor edits (such as just rotating the image, simply lightening it a bit or the like) and major
edits (anything that's going to take you more than five or ten minutes a picture). One re-save
doesn't hurt, so just do your minor edits and save the file, remembering the warning about
EXIF
data given in Definitions.
- You might find yourself working on a file that needs major editing
for a goodly while, during which time you'll want to save it. Therefore,
convert the file to TIFF or your image application's own working format.
This format will be lossless, so you can save as many times as you want
without concern. Also, working formats typically remember other useful
information, like Undo steps. When you've got what you want, you can
then save as a JPEG (or just leave it as TIFF if you have the disk space).
- No matter which file format or function you
are using, avoid progressive transformations as these can subtly degrade
an image. For instance, when trying to level a horizon, if you try 1
degree and it's not enough, don't then try rotating another 1 degree.
Instead, undo the first rotation and try a 2-degree rotation. By the
same token, don't make a photo lighter, then lighter again; undo the
first change and lighten to a greater extent in a single step.
Which Quality Or Compression Level?
It's not possible to say definitively, "Use this setting for this" and "that setting for that"
about JPEG Quality/Compression settings because the JPEG file format does not specify the way that
camera or software manufacturers define quality or compression levels, so – for maximum confusion
– everyone does it their own way. They even name everything in their own way, and different ways
within the same application. For instance in Photoshop Elements, you can Save a JPEG in a
range from 0 to 12 or Save For Web in a range from 0 to 100. Your camera manufacturer may
use terms like Fine, High, Medium and Low. They may use just three of those terms or all four, and
they may be quite vague about what they mean. One camera-maker uses one to three stars, which deserves a prize for dumbing-down.
Here, however are some ideas:
- Buy a bigger memory chip for your camera so you can use the top or near-top quality settings
in the camera without running out of space. Then, edit pictures down on your computer if you need to.
There is nothing more maddening than taking a super photo, then realizing that it's so small and low
quality, you can't do anything with it.
- Be sure to keep original, untouched copies of all these files, so you
can go back to them if you don't like your edits (see above).
- Most image-editing programs now let you preview your image at one or
more compression settings. Use these to make sure you've got what you
need. If your application doesn't have this option, use the Save
As command to make two or three copies at different settings, then
look at them in your browser.
- Before you settle on a quality setting and start doing a lot of work
with it, check it out in the medium in which the photos will be viewed.
If you're going to print a collection of pictures, run some test prints.
If you're going to put them on the Web, prepare a sample and test them,
either by viewing in a browser or by actually uploading them to a site.
You may be surprised, either way.
- If you need to make the files smaller so you'll have enough space for anticipated needs (a trip, for instance),
reduce the pixel dimensions. Scaled-up good-quality JPEGs usually make better prints than full-size low-quality
JPEGs. (And consider buying more memory for your camera – it's getting cheaper all the time.)
- Some pictures are beauty shots (a beautiful flower, a vacation spot), some are just for information (a
reminder of where you planted your bulbs in the fall, how the contractor ran cables inside a wall, etc.).
For beauty, use a quality/compression setting in the mid-range; for an information shot, low-mid or low will do the job.
- For a Web site, take full advantage of the fact that JPEG compression seems to offer the best trade-off in
the middle of the quality/compression continuum. For instance, the morning glory photo used in the article on
JPEG artifacts came in at 104 Kb as a top-quality JPEG, but just 32 Kb at Photoshop Elements' 60 (on a 100-to-0
scale) setting – which gives excellent appearance. Taking the picture down to a 3 setting on the same
scale reduces the file size to 8 Kb – but the appearance is severely degraded. It varies according to
the type of image, but the 'sweet spot' seems to be somewhere in the middle.
|