HOME
TOPICS
ABOUT ME
MAIL

 
PNGs can cut an image down to anywhere from one-half to one-third of its normal file size without any loss of data.
  technofile
Al Fasoldt's reviews and commentaries, continuously available online since 1983

Why you should not use JPEGs for image storage


Sept. 23, 2001


By Al Fasoldt
Copyright © 2001, Al Fasoldt
Copyright © 2001, The Syracuse Newspapers

   If I were king, I'd banish JPEGs forever.
   JPEGs (pronounced "jay-pegs," and sometimes spelled "JPGs") are the images you see all over the Web. Pictures stored as JPEGs are highly compressed so they can be sent across the Internet faster. A picture that takes up 1 million bytes can be squeezed down to 1/10th of that size if you turn it into a JPEG.
   That would seem like a good idea. But it's actually a good idea gone bad. JPEGs are like jigsaw puzzles that can never be put back together again right. Pieces will always be missing. Every time you change a normal image into a JPEG, you lose part of the picture. You can never get it back.
   Remember that. I'll repeat it in a slightly different way to help out: When you create or save a JPEG image, you lose part of the picture and you simply can't get it back, ever.
   JPEGs are losers. They use what's called "lossy" compression. To squeeze an image's file size down to something really small, the JPEG process tosses out 80 or 90 percent of the information and fakes a lot of the rest. JPEGs take advantage of a trick of our eyesight. When we see part of a small, familiar object, we automatically fill in the rest of it. JPEG processing breaks an image up into a lot of small pieces and strips out a great deal of detail from each small piece.
   A picture of your grandmother holding a shawl might show every detail ordinarily, but a JPEG version might not show the way her fingers wrap around the fabric. Instead, they might be depicted as areas of light and dark contrast that suggest an old woman's fingers. Your eyes and brain do the rest. They turn what is only a suggestion of fingers into what your brain thinks is the real thing.
   This might be fine for some uses. But anyone who cares about digital photography should consider JPEG as an enemy, not a friend. I'll bet you don't want that picture of grandma turned into someone who looks sorta like grandma. You want the real thing.
   JPEGs are one-way trips to the Badlands. Here's a familiar scenario. You have a normal, non-compressed image. It's a Windows bitmap, maybe. (They're BMP files.) You open this bitmap in your image-editing software and save it as a JPEG. The file is a LOT smaller. You celebrate a little. What a trick you just pulled!
   Later, you realize you need to tweak the picture a little. Maybe you need to crop it. Maybe you just want to make the colors more vivid.
   So you open the JPEG in your image editor, make your changes and save the file as a JPEG again.
   Ouch. Double ouch!
   Or, as a JPEG word processor (if there ever could be such a thing) might write it, Ouc! Dbl ouc! The image you cropped or tweaked can't be the same as the one you started with. It was already chopped up a lot by the JPEG processing, and when you saved it again it got chopped and diced some more.
   Baaad idea. JPEGs should be banned. Send them all to Devil's Island.
   Well, maybe that's too drastic. I might relent. JPEGs could be let back into polite company if they reformed themselves.
   What could they do to get back in our good graces? They could turn themselves into PNGs.
   The PNG image format is the best thing since the wheel. PNG (pronounced "Ping," not "Pea En Gee") means "Portable Network Graphics." When you save an image as a PNG, nothing gets sliced or diced. A PNG is almost surely going to be smaller than a standard uncompressed image, but it won't have any wounds. Cut it up all you want, slice it hither and yon. It will be all there, even though it's smaller.
   This miracle is actually just a trick of counting. We all do the same thing that PNGs do. We learned this trick in grade school.
   Here's how it works. Suppose you have a lot of sheep to count. You could count every single one of them. Boring, right? Or you could count them by twos. Or maybe, if your eye is quick, you could count them by threes.
   Let's say you've done this -- maybe you were trying the old technique of counting sheep to get to sleep but it didn't work (hint: It never does) -- and now it's time to come up with the real number. If you counted by twos, you just multiply your total by two. If you counted by threes, you multiply your number by three.
   Cool, right? You're storing something like 31 in your brain, but you can quickly turn that into the real number -- 62 or 93.
   Take this a logical step further. Your brother-in-law wants you to stop at the store to pick up some beer for the barbecue. How much? "Three six-packs," he says. Not 18 bottles. Three six-packs. Three times six.
   It's all shorthand. It's a perfectly sane mathematical trick. PNG uses the same approach. It squeezes the data in an image file using tricks of math. Does the image have 61 pixels of nothing but azure blue in one area? PNG stores that information as an instruction to make an azure blue pixel 61 times. That takes up a lot less space than something like this: azure blue pixel, azure blue pixel, azure blue pixel, azure blue pixel, azure blue pixel, azure blue pixel, azure blue pixel ... you get the point.
   The best part of this trick is the way it can be totally reversed without losses. Your brother-in-law doesn't expect the "three" in his instructions to translate to three beers. (In fact, he might not even speak to you again if you produced only three Buds instead of 18.) The mathematical shorthand in his instructions translate into completely accurate information. The family picnic ends up with 18 beers. It matters not at all that nobody ever said "18" when you were heading for the store.
   Likewise, the sky looks exactly the way it was supposed to in the image with all those azure blue pixels. Storing information by listing it as "1 pixel times 61" is the same as storing 61 pixels. Except that it doesn't take up all that wasted space.
   PNGs can't quite squeeze images as much as JPEGs can. There's no way to do it the lossless way and get the same reduction in file size. But PNGs can cut an image down to anywhere from one-half to one-third of its normal file size without any loss of data. Some images can be reduced even more.
   I took a few hundred uncompressed digital images and changed them from BMP to PNG to find out how much space I could save. Most of them were 12 megabyte files stored as BMPs. (That's how big the uncompressed scans are from my PrimeFilm 1800 film scanner. I have a lot of these scans.)
   PNG squeezed these scans down to a little less than half their uncompressed size on average. Some scans, especially ones that did not have much detail, compressed a lot more. But since I started storing most of my digital images as PNGs, I've come to expect about a 50 percent to 60 percent savings in file space.
   That might not seem like much compared to the way JPEG squeezes images, but it's a huge bonus when you realize that PNG is harmless. Images are not changed in any way.
   Good image viewers and editors know how to deal with PNG. If you don't see PNG listed as an option in your image editor's "Save As" menu (under the "File" menu), you have old software and should get a newer version.
   If you don't have an image viewer of any kind, buy ACDSee, available for both Windows PCs and Macintoshes. Windows users who don't want to spend anything should get Irfan View. Both of them let you convert from any standard image format to PNG or back again. You'll find more information on both of them on my Web site, twcny.rr.com/technofile. Search for them by name.