Tag Archives: jpg

When to Use JPEG

Today we’ll learn about the JPEG format — where it excels, where it falls short, and when you want to use it.

JPEG is a way of making that image file smaller, which we learned is often a good thing. However, part of the way that JPEG makes the file smaller is by losing some of the sharper transitions of color or intensity. This is called “lossy compression”, which simply means that in the process of making the file smaller some information about the image is lost. The size savings can be pretty significant — that 10 MB “raw” file on my camera is about 5 MB when saved as a high quality JPEG, and goes down to less than 100 kB (about 1% of the raw file size) when I tweak a couple of settings.

When to throw away pixels and color information

When I take that 10 MB raw file and save it as a 100 kB file to send in an email, I’m losing a lot of information. However, if the person who gets the photo is just looking at it on their computer screen, they will probably never notice. This is because of pixels per inch and color depth.

One of the tweaks I made to the file when I made it smaller was to change the file from the (approximately) 3000 pixels by 2000 pixels that my camera stores to 600 pixels by 400 pixels. With that setting, the photo software takes its best guess as to what will make the picture look about the same, and throws away the rest. This is actually a good thing, because the recipient’s computer monitor probably displays 72 pixels per inch. If they tried to display the original picture at full size, they would have an image over 40″ across, which isn’t very convenient. Their email program would probably shrink the image down, losing the pixel information anyway, and it won’t make as good of a guess about image quality as my photo software will.

Color depth is another reason why we can lose information and not have it matter for the monitor. If you have an average monitor, your computer can show about 16 million different colors. Each different color can be represented inside your computer with 24 bits (a bit is a 1 or a 0). That’s a lot of colors, and is plenty for looking at my cute puppy photo on the monitor. But my camera stores about 4 trillion different colors, which needs 42 bits — almost twice as many 1’s and 0’s as the monitor uses. If we’re willing to give up the colors your monitor can’t display, we can save half the file size.

When do you want to keep the extra pixels and color information?

Picture of cute dog

Obligatory cute dog

If I’m printing the picture of my cute puppy, I want every one of those pixels. Even fairly old cheap printers can handle 300 dpi (dots per inch — like a pixel on your monitor), which means if I want an 8×10 puppy print, I need all 3000 x 2000 pixels in the original. Many printers can handle even more dpi, so even a wallet-sized photo can use all the pixels. This is why when you upload a photo to a photo-printing website they may tell you that you can’t print the larger sizes they have available — they know that you don’t have enough pixels for the picture to look good at those large sizes.

When do you want to keep the colors your monitor can’t display? If you are going to be playing with the image, say to bring out the contrast in the shadows or fix skin tones, you will get the best results if you start with the most color information. Remember, you can always save to a smaller file size after you are done.

When to use JPEG

JPEG is the workhorse of picture formats. Most of the photos you get in emails are JPEGs, as are most of the photos you see on websites. If it’s a photo and you don’t have a really strong reason to use another format, JPEG is usually a good choice.

Photos and Your Computer: The Basics

Besides surfing the web and sending email, one of the most common reasons for people to get a computer is pictures. Whether it’s scanning old photos to share, uploading digital pictures to an online photo album, or sending your camera phone pictures to Facebook, just about everyone has some use for digital pictures. There are a lot of good photo editing software packages out there that make common adjustments to photos easy to do. But with that software often comes a bewildering choice — what format to save the end result in?

First we need to know a little bit about digital photos. Digital photos are made up of a grid of little dots called pixels. If you’ve seen a photo say that it’s 400 x 300, that means it’s 400 dots across and 300 dots high. When the dots are small enough, our eyes blend it all into one smooth picture. Each of those dots has a number associated with it that also tells the computer what color the dot is and how bright that color is. There are different ways to code the color and brightness information, but it still comes down to storing a number for that pixel.

So why do we have different formats? It all comes down to size.

Let’s say you have a 5 megapixel camera. Not very large as cameras today go. 5 megapixels is 5 million pixels. Each of those pixels has a number associated with it. My digital camera stores the color information in about 2 bytes of data per pixel, which means each picture is about 10 megabytes in its raw format. If I want to email a dozen pictures to a friend, especially a friend with a slow internet connection, they aren’t going to be very happy about the size of those photos.

What can be done? Well, a lot of pictures have relatively large patches of the same color. Your computer might notice that there are 100 pixels in a row of blue sky. So instead of storing the number for sky blue 100 times, it make a notation of the color and that it will be repeated 100 times — storing just two pieces of information instead of a hundred. This is called compression and it makes the file smaller, making everyone is happier.

Naturally, it’s not quite that easy in real life. We might think the sky is just blue, but each pixel might be just one shade of blue different from the next pixel. Now instead of saying we have 100 pixels of sky blue, your computer starts storing twice as much information as the original, because it is storing a color, saying it repeats for a single pixel, storing another color, saying that repeats for another pixel, etc.

What to do? This is where the different formats come in. Each format has strengths a weaknesses — one format may make the photo’s file size smaller, but at the cost of quality. Another format may have a special feature or two that are really useful in some situations and not others. In the next few posts we’ll go over some of the common formats, where they excel, and where they fall short. Then when you are faced with a choice of formats, you’ll be confident you’re choosing the best one for your needs.