Sei sulla pagina 1di 32

Image File Formats - JPG, TIF, PNG, GIF Which to use?

The most common image file formats, the most important for cameras, printing, scanning, and internet use, are JPG, TIF, PNG, and GIF.

Digital cameras and web pages normally use JPG files - because JPG heroically compresses the data to be very much smaller in the file. However JPG uses lossy compression to accomplish this, which is a downside. A smaller file, yes, there is nothing like JPG for small, but this is at the cost of image quality. This degree is selectable, to be lower quality smaller files, or to be higher quality larger files. In general today, JPG is rather unique in this regard, using lossy compression allowing very small files of lower quality, whereas almost any other file type is lossless (and larger). Frankly, JPG is used when small file size is more important than maximum image quality (web pages, email, camera memory cards, etc). But JPG is good enough in many cases, if we don't overdo the compression. Perhaps good enough for some uses even if we do overdo it (web pages, etc). But if you are concerned with maximum quality for archiving your important images, then you do need to know two things: 1) JPG should always choose higher Quality and a larger file, and 2) do NOT keep editing and saving your JPG images repeatedly, because more quality is lost every time you save it as JPG (in the form of added JPG artifacts... pixels become colors they ought not to be). See JPG link at page bottom. TIF is lossless (including LZW compression), which is considered the highest quality format for commercial work. The TIF format is not necessarily any "higher quality" per se (the image pixels are what they are), but there simply are no additional losses or artifacts to degrade and detract. And TIF is the most versatile, except that web pages don't show TIF files, because some browsers do not show TIF images. For other purposes however, TIF does most of anything you might want, from 1-bit to 48-bit color, RGB, CMYK, LAB, or Indexed color. Most any of the "special" file types (for example, camera RAW files, fax files, or multipage documents) are based on TIF format, but with unique proprietary data tags - making these incompatible unless expected by their special software. GIF was designed by CompuServe in the early days of computer 8-bit video, before JPG, for video display at dial up modem speeds. GIF is lossless, but it is always an indexed color file (8-bits, 256 colors maximum), and is poor for 24-bit color photos. Don't use GIF for color photos today, the color is too limited. But GIF is still very good for web graphics (i.e., with a limited number of colors). For graphics of only a few colors, GIF can be much smaller than JPG, with more clear pure colors than JPG). This option is called Indexed Color, see Color Palettes (second page of GIF link below). PNG can replace GIF today, and PNG also offers many options of TIF too (indexed or RGB, 1 to 48-bits, etc). One additional feature of PNG is transparency for 24 bit RGB images. Normally PNG files are a little smaller than TIF LZW (both use lossless compression, of different types), but PNG is perhaps slightly slower to read or write. PNG was designed relatively recently for the purpose to bypass possible patent restrictions on LZW compression (used by GIF and TIF). That patent situation has gone

away now, but PNG remains excellent. Less used than TIF or JPG, but PNG is another good choice for lossless quality work. Camera RAW files are very important of course, but only for the very specific use. RAW files must be processed to regular formats (JPG, TIF, etc) to be viewable and usable in any way, but RAW offers substantial benefit in doing that. The debate goes on, some cannot imagine NOT taking advantage of the greater opportunities of RAW. Others think any extra step is too much trouble, and are satisfied with JPG - my own biased opinion is they just don't know yet. :)

Best file types for these general purposes:


Photographic Images Photos are continuous tones, 24-bit color or 8-bit Gray, no text, few lines and edges TIF or PNG (lossless compression and no JPG artifacts) Graphics, including Logos or Line art Graphics are often solid colors, with few colors, up to 256 colors, with text or lines and sharp edges PNG or TIF (lossless compression, and no JPG artifacts) TIF LZW or GIF or PNG (graphics/logos without gradients normally permit indexed color of 2 to 16 colors for smallest file size)

Properties

For Unquestionable Best Quality

Smallest File Size

JPG with a higher Quality factor can be decent.

Maximum Compatibility (PC, Mac, Unix)

TIF or JPG

TIF or GIF

Worst Choice

256 color GIF is very limited color, and is a larger file than 24 -bit JPG

JPG compression adds artifacts, smears text and lines and edges

These are not the only choices, but they are good and reasonable choices. Major considerations to choose the necessary file type include:

Compression quality - Lossy for smallest files (JPG), or Lossless for best quality images (TIF, PNG). Full RGB color for photos (TIF, PNG, JPG), or Indexed Color for graphics (PNG, GIF, TIF). 16-bit color (48-bit RGB data) is sometimes desired (TIF and PNG).

Transparency or Animation is used in graphics (GIF and PNG). Documents - line art, multi-page, text, fax, etc - this will be TIF. CMYK color is certainly important for commercial prepress (TIF).

See chart near bottom of page. We select the file type that supports the options we need. The only reason for using lossy compression is for smaller file size, usually due to internet transmission speed or storage space. Web pages require JPG or GIF or PNG image types, because sone browsers do not show TIF files. On the web, JPG is the clear choice for photo images (smallest file, with image quality being less important than file size), and GIF is common for graphic images, but indexed color is not normally used for color photos (PNG can do either on the web). Other than the web, TIF file format is the undisputed leader when best quality is desired, largely because TIF is so important in commercial printing environments. High Quality JPG can be pretty good too, but don't ruin them by making the files too small. If the goal is high quality, you don't want small. Only consider making JPG large instead, and plan your work so you can only save them as JPG only one or two times. Adobe RGB color space may be OK for your home printer and profiles, but if you send your pictures out to be printed, the mass market printing labs normally only accept JPG files, and only process sRGB color space.

Difference in photo and graphics images


Photo images have continuous tones, meaning that adjacent pixels often have very similar colors, for example, a blue sky might have many shades of blue in it. Normally this is 24-bit RGB color, or 8-bit grayscale, and a typical color photo may contain perhaps a hundred thousand RGB colors, out of the possible set of 16 million colors in 24-bit RGB color. Graphic images are normally not continuous tone (gradients are possible in graphics, but are seen less often). Graphics are drawings, not photos, and they use relatively few colors, maybe only two or three, often less than 16 colors in the entire image. In a color graphic cartoon, the entire sky will be only one shade of blue where a photo might have dozens of shades. A map for example is graphics, maybe 4 or 5 map colors plus 2 or 3 colors of text, plus blue water and white paper, often less than 16 colors overall. These few colors are well suited for Indexed Color, which can re-purify the colors. Don't cut your color count too short though - there will be more colors than you count. Every edge between two solid colors likely has maybe six shades of anti-aliasing smoothing the jaggies (examine it at maybe 500% size). Insufficient colors can rough up the edges. Scanners have three modes to create the image: color (for all color work), grayscale (like B&W photos), and lineart. Line art is a special case, only two colors (black or white, with no gray), for example clip art, fax, and of course text. Low resolution line art (like cartoons on the web) is often better as grayscale, to add anti-aliasing to hide the jaggies. JPG files are very small files for continuous tone photo images, but JPG is poor for graphics, without a high Quality setting. JPG requires 24-bit color or 8-bit grayscale, and the JPG artifacts are most noticeable in the hard edges of graphics or text. GIF files (and other indexed color files) are good for graphics, but are poor for photos (too few colors possible). However, graphics are

normally not many colors anyway. Formats like TIF and PNG can be used either way, 24-bit or indexed color - these file types have different internal modes to accommodate either type optimally.

What does JPG Quality Losses mean? What are JPG artifacts?
The next images (snapshot on a cruise ship) are saved with JPG compression of 20 to 100 JPG Quality, and also one PNG (lossless compression). TIF would look the same as PNG (both are lossless), but some browsers don't show TIF files. The JPG files were saved with Irfanview 4.33 menu File - Save AS - JPG. Faststone 4.6 gives, IMO, identical results and sizes, no differences I can see - guessing that they possibly share the same code library. However, there are several parameters involved with JPG compression, and there are option differences. The details are not just a single number, so the same numerical value is not necessarily the same exact effect in different programs. Irfanview JPG Quality runs 1..100, but Adobe Photoshop has two scales, 0..12 in Save As (more conservative, less compression), and another 0..100 in Save For Web, which is different itself. Generally if using JPG for your good photo images, do start at a high value, like 9 or 90. You should learn to recognize JPG artifacts. There are a couple of types of JPG artifacts, 8x8 pixel blocks (of same one color in the block) in smooth featureless areas, and harsh artifacts around sharp edges. Dirty colors vs pure colors is one result. Viewing at 3x actual size helps to learn to see JPG artifacts. They are real, regardless if you are aware or not. This image is a 300x300 pixel crop from a 4288x2848 12-megapixel RAW image (Nikon D300), so no JPG was involved until output here. All are of course identical copies of the same one image, just with different text and JPG compression added. Image size 300x300 pixels Data 3x 300x300 = 264 KB = 100% Most of the above look decent enough at first, but repeated next are the SAME exact seven files again, same image files simply shown a second time from your browser's cache, but now with browser instructions to enlarge them for a better look at the artifacts (but interpolation is necessarily a blurring operation). File sizes for this image: JPG 20 - 8 KB - 3% JPG 40 - 11 KB - 4% JPG 60 - 14 KB - 5% JPG 80 - 21 KB - 8% JPG 90 - 29 KB - 11% JPG 100 - 77 KB - 29% PNG - 144 KB - 55% TIF LZW - 184 KB - 70%

This is how the images came out of the JPG files (but enlarged now, by interpolation). All were pristine, all the same image going into the files. The differences (between what we put in, and what we get out), is called "losses", due to JPG artifacts caused by lossy compression. Lossy compression means it is allowed to change the data a little (the RGB data is the color of each pixel) to make compression more effective, simply ignoring difficult little details - and the file sure becomes small that way. There are of course diminishing differences with higher Quality, but the PNG just looks sort of "pure" (lossless). The added text is all the same font and the same identical operation for all, but PNG just comes out more pure. This is what is meant by JPG losses. It is about losses of quality - what comes out of the file is simply not as good to look at as what went into the file. THe image is still the same count of pixels, and still three bytes per pixel when opened again, etc, but now some pixels have altered colors, called JPG artifacts... like dirty pixels. Remember, artifacts continue to accumulate, getting worse, every time you edit and Save the file as JPG again. Each Save is lossy compression again. And this is not repairable, so be aware, don't do this repeated times. There are better plans. Make no mistake - JPG 100 is NOT an unaffected image, it is still JPG, and it is NOT a perfect copy. Above is the pixel difference in the original JPG 100 image and the PNG image, as shown by the Adobe Photoshop CS5 Calculations tool, when comparing only the blue channels (red channels look essentially the same as this, but the green channels are pretty dark in this one). This is enlarged some, but is shown at default brightness, the actual difference, no fudged adjustments. Seems to me the differences are in the anti-aliasing on the edges (almost like a line drawing). They were the same image with the same pixels, until compression, so my notion is that JPG apparently didn't consider saving all of these infrequent colors as important. Faststone has a menu that counts colors in images, and reports the PNG image has 35,046 colors, and the JPG 100 image has 23,368 colors (only 2/3 as many now - there are more in the lower JPG values, which are the artifacts maybe. Photoshop JPG does the same reduction of colors, in about the same degree.) The JPG 100 file, when saved again now as PNG, is nearly 5% smaller than the original PNG file, its modified data is easier to compress now. If you start your comparisons with a JPG image, you may not see this much difference now, but remember, this file started out as RAW, it had never seen JPG before. This may be minor visually, but we cannot argue that they are still identical images. We might argue "good enough", and it probably is (numerical differences instead of visual). If this is the master copy of our prize image, we may not be willing to consider any argument at all about quality. But JPG Quality 100 is pretty good, and the file sure is small. I would have no concern about sending the JPG 90 or 100 images out to be printed (printers gloss over small details too), but not to keep as my archived master copy. The actual worry is about creating more differences next time it is saved as JPG. JPG artifacts accumulate at every Save as JPG (compressed again at every Save). The only point here is that even JPG Quality 100 is definitely always still JPG, and it is never going to be lossless compression. In contrast, lossless means every pixel's data value (color) comes back out of the file exactly the same as what when in - no artifacts. That's always a good thing, if quality is the major concern.

Speaking on a 1..10 scale (Adobe), JPG Quality 4 might sometimes be "good enough" for some unimportant web page images, especially back in dial-up days. We could debate it, but Quality 10 may Not be good enough to archive your prized best pictures, at least not for mine. For your good stuff, you should always use a high value, maybe not quite the absolute highest, but high, at least 9. The degree of compression varies with the saving program, and also with image scene detail. Sort a large folder by file size, of many varied JPG images all of same original camera size, and they will vary maybe over a 2:1 size range (depending on scene content). Large blank areas, like sky and walls, compress much smaller than extremely detailed areas, like a tree full of leaves. That said (different scenes vary in file size, and programs vary too), and so speaking very generally, the average JPG file size ought to be at least 10% of the data size to be "decent". Use at least Quality 9 for your good stuff. I would consider High Quality as being 20% of data size (24-bit data size is three bytes per pixel). If you ever saved it ONCE at lower quality, lower is the best you've got now. The larger you can make the JPG file, the better quality the image will be (and JPG is still tiny, compared to the size of the data). See following JPG pages. And BTW, another factor, excessive USM sharpening is another factor that can also cause false edges, and sharpening aggravates the JPG artifacts around sharp edges. If you want the smallest file with less artifacts, blur it very slightly before saving it. JPG Quality 10 is pretty good indeed, but it is still JPG. JPG is used where small file size is more important than absolute image quality, like web pages or email, or small memory cards. Conversely, if absolute image quality is important, why consider JPG at all? JPG Quality 8 to 10 may be "good enough" for most "viewing" uses, EXCEPT there is the distinction that JPG is not good for editing, involving saving repeated times - which accumulates and compounds the JPG artifacts each time saved as JPG. Your images are either important or not, and maybe not your biggest concern, but if we take liberties, experience knows the time will always come when it will matter. We cannot undo JPG damage. There are always ifs and buts, difficult to quantify. There are lossless methods to rotate or flip JPG images, rearranging and rotating the 8x8 pixel blocks without uncompressing and recompressing (Irfanview plugins offers this), so there are no additional losses in those special cases. Applications like Photoshop take heroic pains to try not to recompress image areas with no change (when possible, has to be the same Quality level too). But bottom line, saving JPG again is a little like Russian Roulette - every time may not get you, but there certainly are risks, and when it does bite us, it always seems at the worst possible time. Some people really don't notice much difference, so about anything is "good enough" (until it bites them bad, the only copy of their prized image is now full of JPG artifacts - from repeated edits and saves, and/or due to specifying a Quality factor too low). There are other more critical photographers (who probably have been bitten before) thinking that even the very best is barely sufficient for THEIR images. We cannot reason with either one. :) Certainly we cannot have the same discussion with both. Risk of course depends on how important your images are, and there are times and places for both approaches, but I lean towards the latter group. Photography is too much time and money invested trying for greater quality, so I really don't see any reason to intentionally select less than maximum quality. Regarding my images, I'm not interested in any debate about how little it might hurt. Internet transmission speed can be a consideration at times,

but today, inexpensive disk space rules out any reason to compromise my image quality, certainly not my original copies. Indeed, there are better ways to go about it.

The Best Plan When We Need JPG


For those who critically care about their images, the best plan, and actually, the easy way, is to always keep and archive your unedited original image as the best master you will ever have. Otherwise, you can never get it back, so never write over it - always keep that original intact for just in case (whatever it is, especially if it is a JPG from the camera - and the camera should of course be set to create the finest possible image it can.) Then when editing (saving only to a copy, always preserving the original intact), always save your in-work image ONLY to a lossless format (TIF or PNG), EVERY time, UNTIL your last necessary FINAL one JPG save (at high quality level). For example, Photoshop, and the free editors Irfanview and Faststone (see Google), have batch modes to copy many files from JPG to TIF in one easy operation. This would be pointless unless you are intending to edit them, because this TIF step will NOT remove any existing JPG artifacts, the data will of course still contain those original JPG artifacts - but subsequent TIF Saves will not add any more. Computers and disks are big and fast and inexpensive today, this larger file size is a small issue today (and that is simply how big your data is). Then as lossless TIF files, you can edit away, red eye and color and contrast adjustments, straightening and cropping and resampling, and saving with wild abandon (just NOT as JPG), until that needed One Final JPG Save. So if it was JPG previously, now the total is only two saves as JPG (original camera save, and this one final save, is two), which is worse than one, but much better than six. Using camera RAW images would also eliminate the first JPG, and offer other advantages too. And then, when if any further need to edit it again comes up (resample size, whatever, anything requiring another Save As JPG), discard this second JPG (as an expendable copy), and start over from your better archived master you kept. Avoid using any image saved repeated times as JPG. JPG is lossy, which means we do not get back the same quality we put in. There are more losses every time it is saved as JPG. With lossless formats (PNG or TIF LZW), it does not matter if you save a jillion times. But it matters if saving to JPG. An extra unthinking save as JPG is never a good plan. If it overwrites your only original copy, it is a terrible plan, you can never get it back. Batch processing: Speaking of the philosophy of expendable JPG, and assuming you keep a high quality lossless archive, then there are easy ways to run off batches of expendable JPG for oneuse viewing, temporary JPG copies sized for monitor viewing, or for HDTV viewing, or to upload to be printed, etc. Several programs have batch modes to do this. Adobe Photoshop has its menu File - Scripts - Image Processor. It can read Camera RAW images, including their previous processing instructions (White Balance, Exposure, Cropping, etc). Also can apply Actions as it goes. Faststone editor has its menu Tools - Batch Convert Selected Images. Free from the internet. Irfanview editor has its menu Files - Batch Conversion/Rename. Free from the internet.

Of these two free programs, IMO, Faststone is the better editor (more conventional and complete), and Irfanview may be the better viewer (less cluttered). Here is the trick: We always resample using "Preserve Aspect Ratio", so generally, if you want say 1800x1200 pixel size (to print 6x4 inches), you can specify the larger target dimension twice, 1800x1800, and then regardless if the batch contains mixed landscape or portrait shapes, the largest dimension will be 1800, as appropriate. Aspect ratio controls the smaller dimension, which can be however you prepared it. Or the Photoshop batch has its Resize to Fit option, and the Faststone batch has its Switch Width with Height option to do this same trick more overtly. Computer speed today makes it trivial to just run off whatever size you want at the moment, and then discard those expendable JPG after that one use. You always have your high quality lossless archive copy, and can do this at will.

Basics
Our digital images are dimensioned in pixels (not bytes, and definitely not inches). And a pixel is simply a color definition, the color that this tiny dot of image sampled area ought to be. Put all those colored dots together, and our brain sees the image. The losses of image data we are speaking about is about the altered color of the pixels. Image data consists of pixels, and pixels are "colors", simply the storage of the three RGB data components (see What is a Digital Image Anyway?). Any 24-bit RGB image will use three bytes per pixel (see Color Bit-Depth - Memory Size). So - for example- any 10 megapixel camera image data will occupy 3x10 = 30 million bytes, by definition of RGB color. This number is the "data size" (when opened into computer memory for use). A TIF file will be near that size (and is lossless), but JPG is normally compressed very heavily (lossy, not lossless) to store in a JPG file of perhaps 1/10 this size (variable with JPG Quality setting), which is "file size" (not image size and not data size). This example image size is still 10 megapixels (dimensioned in pixels, width x height), and the data size is 30 million bytes, but the JPG file size might be 3 MB (lossy compression takes a few liberties). The image will still come out of the JPG file as the same 10 megapixels and the same 30 million bytes when the 3 MB JPG file is opened. We hope its quality also comes out about the same - the JPG losses are altered color values of some of the pixels). Image size (pixels) determines how we can use the image - everything is about the pixels. See a summary of digital basics. All photo editor programs will support these file formats, which will generally support and store images in the following color modes: Color data mode -bits per pixel

RGB - 24-bits (8-bit color), Grayscale - 8-bits (only these) JPG JPEG always uses lossy JPG compression, but its degree is selectable, for higher quality and larger files, or lower quality and smaller files. JPG is for photo images, and is the worst possible choice for most graphics or text data. Versatile, many formats supported. Mode: RGB or CMYK or LAB, and others, almost anything. 8 or 16-bits per color channel, called 8 or 16-bit "color" (24 or 48-bit RGB files). Grayscale - 8 or 16-bits, Indexed color - 1 to 8-bits, Line Art (bilevel)- 1-bit For TIF files, most programs allow either no compression or LZW compression (LZW is lossless, but is less effective for color images). Adobe Photoshop also provides JPG or ZIP compression in TIF files too (but which greatly reduces third party compatibility of TIF files). "Document programs" allow ITCC G3 or G4 compression for 1-bit text (Fax is G3 or G4 TIF files), which is lossless and tremendously effective (small). Many specialized image file types (like camera RAW files) are TIF file format, but using special proprietary data tags. 24-bits is called 8-bit color, three 8-bit bytes for RGB (256x256x256 = 16.7 million colors maximum.) Or 48-bits is called 16-bit color, three 16-bit words (65536x65536x65536 = trillions of colors conceptually) RGB - 24 or 48-bits (called 8-bit or 16-bit "color"), Alpha channel for RGB transparency - 32 bits Grayscale - 8 or 16-bits, Indexed color - 1 to 8-bits, Line Art (bilevel) - 1-bit Supports transparency in regular indexed color, and also there can be a fourth channel (called Alpha) which can map RGB graduated transparency (by pixel location, instead of only one color, and graduated, instead of only on or off). PNG also supports animation (like GIF), showing several sequential frames fast to simulate motion. PNG uses ZIP compression which is lossless, and somewhat more effective color compression than TIF LZW. For photo data, PNG is somewhat smaller files than TIF LZW, but larger files than JPG (however PNG is lossless, and JPG is not.) PNG is a newer format than the others, designed to be both versatile and royalty free, back when

TIF

PNG

the patent for LZW compression was disputed for GIF and TIF files. Indexed color - 1 to 8-bits (8-bit indexes, limiting to only 256 colors maximum.) Color is 24-bit color, but only 256 colors. One color in indexed color can be marked transparent, allowing underlaying background to be seen (very important for text, for example). GIF is an online video image, the file contains no dpi information for printing. Designed by CompuServe for online images in the days of dialup and 8-bit indexed computer video, whereas other file formats can be 24-bits now. However, GIF is still great for web use of graphics containing only a few colors, when it is a small lossless file, much smaller and better than JPG for this. GIF files do not save the dpi number for printing resolution. GIF uses lossless LZW compression. (for Indexed Color, see second page at GIF link at page bottom). GIF also supports animation, showing several sequential frames fast to simulate motion. Note that if your image size is say 3000x2000 pixels, then this is 3000x2000 = 6 million pixels (6 megapixels). Assuming this 6 megapixel image data is RGB color and 24-bits (or 3 bytes per pixel of RGB color information), then the size of this image data is 6 million x 3 bytes RGB = 18 million bytes. That is simply how large your image data is (see more). Then file compression like JPG or LZW can make the file smaller, but when you open the image in computer memory for use, the JPG may not still have the same image quality, but it is always still 3000x2000 pixels and 18 million bytes. This is simply how large your 6 megapixel RGB image data is (megapixels x 3 bytes per pixel).

GIF

Summary
The most common image file formats, the most important for general purposes today, are JPG, TIF, PNG and GIF. These are not the only choices of course, but they are good and reasonable choices for general purposes. Newer formats like JPG2000 never acquired popular usage, and are not supported by web browsers, and so are not the most compatible choice. PNG and TIF LZW are lossless compression, so their file size reduction is not as extreme as the wild heroics JPG can dream up. In general, selecting lower JPG Quality gives a smaller worse file, higher JPG Quality gives a larger better file. Your 10 megapixel RGB image data is three bytes per pixel, or 30 million bytes. Your JPG file size might only be only 5-15% of that, literally. TIF LZW might be 65-80%, and PNG might be 50-65% (very rough ballpark for 24-bit color images). We cannot predict sizes precisely because compression always varies with image detail. Blank areas, like sky and walls, compress much smaller than extremely detailed areas like a tree full of leaves. But the JPG file can be much smaller, because JPG is not required to recover the original image intact, losses are acceptable. Whereas, the only goal of PNG and TIF LZW is to be 100% lossless, which means the file is not as heroically small, but there is never any

concern about compression quality with PNG or TIF LZW. They still do impressive amounts of file size compression, remember, the RGB image data is actually three bytes per pixel. We all have our own notions, but here is a popular opinion about the ultimate, in quality, in versatility, in convenience. RAW files are popular indeed, from most DSLR cameras. When we take any digital picture, the camera has a RAW sensor, but normally processes and outputs the image as a JPG file. But often we can choose to output the original RAW image instead, to defer that JPG step until later. We cannot view or use that RAW file any way other than to process it in computer software and then output a final TIF or JPG image, however postponing this processing offers a few serious advantages, better editing options, and we can bypass all JPG artifacts entirely, until the one final output Save for whatever purpose. RAW allows us to tweak exposure and color, and defer White Balance decisions until later when we can see the image first, and judge any trial results. The 12-bit RAW file offers greater range for any of our adjustments, often on multiple files simultaneously. And RAW always preserves the intact original version, so we can easily back out any editing changes we made, crop size for example. An argument is made that processing RAW requires this extra step, but of course, same is true of any editing that is required. RAW is the easy way, with the best results.

PNG - Portable Network Graphics


(.PNG file extension, the pronunciation 'Ping' is specifically mentioned in the PNG Specification). PNG needs to be mentioned. PNG is not the number one file format, but you will want to know about it. PNG is not so popular yet, but it's appeal is growing as people discover what it can do. PNG was designed recently, with the experience advantage of knowing all that went before. The original purpose of PNG was to be a royalty-free GIF and LZW replacement (see LZW next page). However PNG supports a large set of technical features, including superior lossless compression from LZ77. Compression in PNG is called the ZIP method, and is like the 'deflate" method in PKZIP (and is royalty free). But the big deal is that PNG incorporates special preprocessing filters that can greatly improve the lossless compression efficiency, especially for typical gradient data found in 24 bit photographic images. This filter preprocessing causes PNG to be a little slower than other formats when reading or writing the file (but all types of compression require processing time). Photoshop 7 and Elements 2.0 corrected this, but earlier Adobe versions did not store or read the ppi number to scale print size in PNG files (Adobe previously treated PNG like GIF in this respect, indicated 72 ppi regardless). The ppi number never matters on the video screen or web, but it was a serious usability flaw for printing purposes. Without that stored ppi number, we must scale the image again every time we print it. If we understand this, it should be no big deal, and at home, we probably automatically do that anyway (digital cameras do the same thing with their JPG files). But sending a potentially unsized image to a commercial printer is a mistake, and so TIF files should be used in that regard.

Most other programs do store and use the correct scaled resolution value in PNG files. PNG stores resolution internally as pixels per meter, so when calculating back to pixels per inch, some programs may show excessive decimal digits, perhaps 299.999 ppi instead of 300 ppi (no big deal). PNG has additional unique features, like an Alpha channel for a variable transparency mask (any RGB or Grayscale pixel can be say 79% transparent and other pixels may individually have other transparency values). If indexed color, palette values may have similar variable transparency values. PNG files may also contain an embedded Gamma value so the image brightness can be viewed properly on both Windows and Macintosh screens. These should be wonderful features, but in many cases these extra features are not implemented properly (if at all) in many programs, and so these unique features must be ignored for web pages. However, this does not interfere with using the standard features, specifically for the effective and lossless compression. Netscape 4.04 and MS IE 4.0 browsers added support for PNG files on web pages, not to replace JPG, but to replace GIF for graphics. For non-web and non-graphic use, PNG would compete with TIF. Most image programs support PNG, so basic compatibility is not an issue. You may really like PNG. PNG may be of great interest, because it's lossless compression is well suited for master copy data, and because PNG is a noticeably smaller file than LZW TIF. Perhaps about 25% smaller than TIF LZW for 24 bit files, and perhaps about 10% to 30% smaller than GIF files for indexed data. Different images will have varying compression sizes, but PNG is an excellent replacement for GIF and 24 bit TIFF LZW files. PNG does define 48 bit files, but I don't know of any programs that support 48 bit PNG (not too many support 48 bit in any form). Here are some representative file sizes for a 9.9 megabyte 1943x1702 24-bit RGB color image: File type TIFF TIFF LZW PNG JPG BMP File size 9.9 megs 8.4 megs 6.5 megs 1.0 megs 9.9 megs (1.0 / 9.9) is 10% file size

Seems to me that PNG is an excellent replacement for TIFF too.

TIFF - Tag Image File Format


(.TIF file extension, pronounced Tif) TIFF is the format of choice for archiving important images. TIFF is THE leading commercial and professional image standard. TIFF is the most universal and most widely supported format across all platforms, Mac, Windows, Unix. Data up to 48 bits is supported. TIFF supports most color spaces, RGB, CMYK, YCbCr, etc. TIFF is a flexible format with many options. The data contains tags to declare what type of data follows. New types are easy to invent, and this versatility can cause incompatibly, but about any program anywhere will handle the standard TIFF types that we might encounter. TIFF can store data with bytes in either PC or Mac order (Intel or Motorola CPU chips differ in this way). This choice improves efficiency (speed), but all major programs today can read TIFF either way, and TIFF files can be exchanged without problem. Several compression formats are used with TIF. TIF with G3 compression is the universal standard for fax and multi-page line art documents (line art). For photographic images, TIFF image files can use LZW lossless compression. Lossless means there is no quality loss due to compression. Lossless guarantees that you can always read back exactly what you thought you saved, bit-for-bit identical, without data corruption. This is a critical factor for archiving master copies of important images. Most image compression formats are lossless, with JPG and Kodak PhotoCD PCD files being the main exceptions. Compression works by recognizing repeated identical strings in the data, and replacing the many instances with one instance, in a way that allows unambiguous decoding without loss. This is fairly intensive work, and any compression method makes files slower to save or open. LZW is most effective when compressing solid indexed colors (graphics), and is less effective for 24 bit continuous photo images. Featureless areas compress better than detailed areas. LZW is more effective for grayscale images than color. LZW is often counter-productive for 48 bit images, the 16 bit TIF file using LZW will probably be considerably larger than one with no compression. (VueScan 48 bit TIF LZW is an exception to this, using an efficient data type that not all others use ). LZW is Lempel-Ziv-Welch, named for Israeli researchers Abraham Lempel and Jacob Zif who published IEEE papers in 1977 and 1978 (now called LZ77 and LZ78) which were the basis for most later work in compression. Terry Welch built on this, and published and patented a compression technique that is called LZW now. This is the 1984 Unisys patent (now Sperry) involved in TIF LZW and GIF (and V.42bis for modems). There was much controversy about a royalty for LZW for GIF, but royalty was always paid for LZW for TIF files and for v.42bis modems. International patents recently expired in mid-2004. It is not necessary to say much about TIF. It works, it's important, it's great, it's practical, it's the standard universal format for high quality images, it simply does the best job the best way. Give

TIF very major consideration, both for photos and documents, especially for archiving anything where quality is important. But TIF files for photo images are generally pretty large. Uncompressed TIFF files are about the same size in bytes as the image size in memory. Regardless of the novice view, this size is a plus, not a disadvantage. Large means lots of detail, and it's a good thing. 24 bit RGB image data is 3 bytes per pixel. That is simply how large the image data is, and TIF LZW stores it with recoverable full quality in a lossless format (and again, that's a good thing). Large disks are inexpensive today. There are situations for less serious purposes when the full quality may not always be important or necessary. JPEG files are much smaller, and are suitable for non-archival purposes, like photos for read-only email and web page use, when small file size may be more important than maximum quality. JPG has its important uses, but be aware of the large price in quality that you must pay for the small size of JPG, it is not without cost.
JPEG - Joint Photographic Experts Group

(.JPG file extension, pronounced Jay Peg). This is the right format for those photo images which must be very small files, for example, for web sites or for email. JPG is often used on digital camera memory cards, but RAW or TIF format may be offered too, to avoid it. The JPG file is wonderfully small, often compressed to perhaps only 1/10 of the size of the original data, which is a good thing when modems are involved. However, this fantastic compression efficiency comes with a high price. JPG uses lossy compression (lossy meaning "with losses to quality"). Lossy means that some image quality is lost when the JPG data is compressed and saved, and this quality can never be recovered. File compression methods for most other file formats are lossless, and lossless means "fully recoverable". Lossless compression always returns the original data, bit-for-bit identical without any question about differences (losses). We are used to saving data to a file, and getting it all back when we next open that file. Our Word and Excel documents, our Quicken data, any data at all, we cannot imagine NOT getting back exactly the original data. TIF, PNG, GIF, BMP and most other image file formats are lossless too. This integrity requirement does limit efficiency, limiting compression of photo image data to maybe only 10% to 40% reduction in practice (graphics can be smaller). But most compression methods have full lossless recoverability as the first requirement. JPG files don't work that way. JPG is a big exception. JPG compression is not lossless. JPG compression is lossy. Lossy means "with losses" to image quality. JPG compression has very high efficiency (relatively tiny files) because it is intentionally designed to be lossy, designed to give very small files without the requirement for full recoverability. JPG modifies the image pixel data (color values) to be more convenient for its compression method. Tiny detail that doesn't compress well (minor color changes) can be ignored (not retained). This allows amazing size reductions on the remainder, but when we open the file and expand the data to access it again, it is no longer the same data as before. This lost data is like lost purity or integrity. It can vary in degree, it can be fairly good, but it is always unrecoverable corruption of the data. This

makes JPG be quite different from all the other usual file format choices. This will sound preachy, but if your use is critical, you need a really good reason to use JPG. There are times and places this compromise is an advantage. Web pages and email files need to be very small, to be fast through the modem, and some uses may not need maximum quality. In some cases, we are willing to compromise quality for size, sacrificing for the better good. And this is the purpose of JPG. There is no magic answer providing both high compression and high quality. We don't get something for nothing, and the small size has a cost in quality. Still, mild quality losses may sometimes be acceptable for less critical purposes. The sample JPG images on next page show the kind of problem to expect from excessive compression. Even worse, more quality is lost every time the JPG file is compressed and saved again, so ever editing and saving a JPG image again is a questionable decision. You should instead just discard the old JPG file and start over from your archived lossless TIF master, saving that change as the new JPG copy you need. JPG compression can be selected to be better quality in a larger file, or to be lesser quality in a smaller file. When you save a JPG file, your FILE - SAVE AS dialog box should have an option for the degree of file compression. Many programs (Photoshop, Elements, PhotoImpact, PhotoDeluxe) call this setting JPG Quality. Other programs (Paint Shop Pro and Corel) call it JPG Compression, which is the same thing, except Quality runs numerically the opposite direction from Compression. High Quality corresponds to Low Compression. Typical values might be 85 Quality, or 15 Compression. These numbers are relative and have no absolute meaning. Compression in one program will vary from another even at the same number. The number is also not a percentage of anything, and Quality 100 does NOT mean no compression, it is just an arbitrary starting point. JPG will always compress, and Quality 90 is not so different from Quality 100 in practice. There's very little improvement over 95. Digital cameras also offer JPG quality choices too. Large image files do fill memory cards fast. You can buy more and larger cards, or you can compromise by sacrificing image quality for small file size (but I hope you won't go overboard with this). The camera menu will have two kinds of resizing choices. One size choice actually creates a smaller image size (pixels), resampled smaller from the original standard size of the CCD chip, for example perhaps to half size in pixel dimensions. The correct image size in pixels is related to your goal for using the image. For example you may need enough pixels to print 8x10 inches on paper (6 megapixels), or you may only want a small image for video screen viewing (1 megapixel). Regardless of that selected image size in pixels, the camera menu will also offer a smaller file size choice in bytes, related to quality, via JPG file compression. This menu will offer a best quality setting which is the largest file, and maybe intermediate sizes, and a smallest but worst quality choice. My Nikon D70 offers three JPG file size choices of Fine (about 1/4 size in bytes), Norm (about 1/8 size in bytes), or Basic (about 1/16 size in bytes), comparing compressed file size to the uncompressed size. The best (largest) JPG file size will still contain JPG artifacts, but very mild, essentially undetectable, vastly better than the smallest file choice. Even better, some cameras also offer a RAW or TIF format to bypass JPG problems all together. These images may

be large, but memory cards are becoming less expensive, and larger or multiple cards are by far the best quality solution. With either scanner or camera images, individual image JPG file sizes will vary a little, because detail in the individual image greatly affects compressibility. Large featureless areas (skies, walls, etc.) compress much better (smaller) than images containing much tiny detail all over (a tree full of leaves). Therefore images of the same size in pixels and using the same JPG quality setting, but with differing image content, will vary a little in JPG file size, with extremes perhaps over a 2 to 1 range around the average size. Since each image varies a little, the file size is only a crude indicator of JPG quality, however it is a rough guide. For ordinary color images (24 bit RGB), the uncompressed image size when opened in memory is always 3 bytes per pixel. For example, an image size of 3000x2000 pixels is 6 megapixels, and therefore by definition, when uncompressed (when opened), this memory size is 3X that in bytes, or 18 MB. That is simply how large the 24 bit data is. The compressed JPG file size will be smaller (same pixels, but fewer bytes). A High quality JPG file size might be compressed to 50% to 25% uncompressed size (bytes). A JPG file size only 10% of that image's size in memory would the general ballpark for a fair tradeoff of quality vs. file size for color images of web page quality (but not best quality). The 10% size is not very precise, but of course only refers roughly to the average image size, since each individual image varies a little. Color compresses better than grayscale files, so grayscale doesn't decrease as much. These are very rough guidelines, your image, your photo program, your purpose, and your personal criteria or tolerance will all be a little different. It is difficult to describe the JPG quality losses, except by seeing an example image (next page). JPG does not discard pixels. Instead it changes the color detail of some pixels in an abstract mathematical way. JPG is mathematically complex and requires considerable CPU processing power to decompress an image. JPG also allows several parameters, and programs don't all use the same JPG rules. Programs vary, some programs take shortcuts to load JPG faster but with less quality (browsers for example), and other programs load JPG slower with better quality. Final image quality can depend on the image details, on the degree of compression, on the method used by the compressing JPG program, and on the method used by the viewing JPG program.
JPEG Artifacts

I am sent JPG images with questions why they appear "bad" and very "unclear", when the only problem is excessive JPG compression, too much, or saved too many times, or both. Too little Quality or too much Compression will affect JPG image quality visibly. It can be awful. You can and should learn to recognize this bad effect yourself. It's easy to recognize, almost trivial, after you've seen it once. Then you will know if it is acceptable or not, and you will know that you have choices.

How to see JPG artifacts the first time

If using a digital camera, shoot the same scene as the best file format you have, a RAW or TIF file, or at least at the best JPG quality setting (largest file). Also shoot exactly the same scene at the lowest JPG quality setting (smallest file). If using a scanner, scan a new photo image and save it as a TIF file. Then, after that, also save the same image as a JPG file using more compression than usual, a lower JPG quality setting this one time to help learn to see it. Then close that JPG image, and reopen that file to be sure you are viewing the contents of the file image you actually wrote (instead of the uncompressed image on the screen that you thought you wrote). Then examine both large and small file images side by side on the same screen, by zooming in to about 4 times size (400%, huge) on both. You will have to scroll around on them, but the 400% is to help you learn to recognize the artifacts this first time. The differences you see are the JPG artifacts of compression. The visible signs of excessive JPG compression are JPG artifacts, which include:

Areas of similar color (generally featureless areas like skies or walls) become "blocky", with tile-like squares that are 8x8 pixel blocks of one color (compresses well), or which may contain horizontal or vertical patterns at extremes. You see the 8x8 squares, like big pixels, but at 400% zoom, you can recognize the size difference in the pixels (jaggies) and the 8x8 pixel blocks. The sharp contrasting edges in the image will have "vague dark smudges" surrounding the sharp edges. This is normally the worst effect in most images, it obsures detail. Excessive JPG compression is tough on all sharp edges in the image (especially so for text and graphic images). This is very counterproductive to apparent sharpness and fine detail. Some false color or color changes.

Here are samples below, zoomed large, but same size and side by side for comparison, to better learn to recognize the JPG artifacts (that is a cookie jar at left, with a little reflection on it) Original TIF image ABOVE, zoomed to 300% size Low Quality JPG image BELOW, zoomed to 300% size Not that it seems necessary, but I have marked a few of the 8x8 pixel blocks seen in areas of similar color, and also some of the smudging around sharp edges (all edges). You can find more almost any place in the image. Notice the missing detail at the ridged knob marked in blue. The two power cords behind the fruit are nearly obscured by JPG artifacts. The tiny jaggies in the TIF are the original pixels zoomed to 300%. Their size is a guide to show the larger JPG 8x8 pixel blocks are clearly a different artifact.

Zooming to 300% size is not the normal thing to do, but it does help to recognize these JPG artifacts the first time. After you learn what you are looking for, then you can recognize them at 100% size too. This sample shows what is meant by "lossy compression" in JPG - the losses are from deteriorating image quality due to the JPG artifacts. Using a Higher JPG Quality setting to produce a larger JPG file improves the JPG image quality. Using a Lower JPG Quality setting to produce a smaller file makes it worse. That seems straight-forward. A High JPG Quality setting of 8 or 9 (assuming a 1-10 scale, but 80 or 90 on a 1-100 scale is used by some software - same thing) is normally a pretty good image, normally not much problem for read-only uses, like viewing or printing (both zoomed images above are in a High quality JPG now for web presentation). The problem then is when you want to edit the image and save it yet again as JPG (additional JPG artifacts accumultate each time). We should only save a JPG image ONE TIME. Note that most other types of image file compression (for example PNG or TIF LZW) are lossless compression, meaning that there is absolutely no loss of quality due to compression (zero loss), so that then file quality is simply not an isssue at all, and the most critical user need not ever worry about it. The TIF file above used LZW compression. However lossless file compression is less effective, meaning that it can not produce files so drastically small as JPG. The lossless file size is closer to the actual size of the color data, perhaps 70% or 80% instead of 5% to 20%. I want to call this JPG an extreme example, and it is poor, but it is not extreme. You ought to see some of the images that people send me asking why their images are so poor. This JPG was done in Photoshop, and Adobe's lowest quality settings are conservative, and won't let us make them as extreme and poor as some other programs will. The JPG quality numbers like 8 or 9 are NOT absolute values, instead they are relative to the JPG properties that each program chooses to individually use. JPG artifacts do vary, and this will be of more concern when you do this same test on your own images. Once you realize what you are looking for, then JPG artifacts are easy to see and recognize at 100% size. Some people are more critical than others, asking "How good can I make it?" instead of "How small can I make it"? Your priorities are your own, but afer you are able to recognize JPG artifacts, you will be able to judge how much of this you want in your own images. Here is another older sample showing JPG artifacts. Use a higher JPG Quality factor to minimize these effects (or don't use JPG at all if maximum quality is important). Less JPG Quality is more JPG compression, a smaller file, but worse artifacts. Normally you may detect some artifacts even at high Quality factors, and you can learn to recognize this easier if you zoom in to about 400% size. But the image can still be very usable size if the compression is mild. Now you know what to look for, and how to look for it, and how to judge if you want it or not.

The JPG artifacts become part of the image data, and it cannot be removed. Sharpening again after JPG compression (next time) will emphasize these JPG artifacts, so be careful with that. Actually, very slight intentional softening or blurring before JPG compression will help minimize the effect of the JPG artifacts (and will slightly reduce JPG file size too). JPG normally should not be used for text or graphic images. It obscures the sharp edges too much, and the results are typically poor. TIF LZW, PNG, and GIF are vastly better for line art or graphic images, and these will normally compress text and graphics effectively. The way to make a scanned text document PDF file smaller is to scan in Line art mode and use compression. Acrobat will use G4 compression which is very small for line art, but LZW is good too. For text, line art will be smaller and better result than a JPG grayscale file. JPG cannot handle line art or indexed color anyway, JPG requires 8 bit grayscale or 24 bit color. However for continuous tone photo images, as opposed to text or graphics, then files with high JPG Quality (low compression) are normally acceptable for viewing (read-only purposes), and the small file size is extremely desirable for modems. Due to the quality concerns, JPG compression is generally NOT suitable for archiving the important master copy of your image. With only mild compression, it might view OK, but you should grit your teeth, hold your breath, and cross your fingers for luck, if you ever have the need to modify and save a JPG file again. Because this will lower the quality of that image even more, every time you save the file. By "save", I mean to select the FILE - SAVE or FILE - SAVE AS or FILE - SAVE FOR WEB menu with JPG format from an image program. That SAVE step does the JPG compression again. Note that downloading, or copying, or opening and viewing JPG files is no problem at all. This does not save the file again, and it does not alter the file in any way, so it does not create more artifacts. You can open and view a JPG file a jillion times without any concern (a web page for example). The artifacts are created only when the data is compressed for saving it as a JPG file. This happens only at the menus FILE - SAVE or FILE - SAVE AS or FILE - SAVE FOR WEB when you select JPG format. Archive your important master copy images in a non-lossy format (TIF LZW and PNG are very good, and compress moderately), and then also make a JPG copy if needed for view-only purposes that need it to be smaller, like email and web pages. You won't gain any quality by converting JPG to TIF now, because that image copy will still contain the JPG artifacts it had before. It is part of the image now, there is no way to improve it again. However, if you do need to edit a JPG, then saving it as TIF will prevent adding more artifacts by not doing another JPG Save, so TIF would be a good plan then. If you find that you must edit the JPG image and must save it as JPG again, at least try to use the same program and same value of Quality or Compression every time you save the file. Using different values will use different parameters that will aggravate the damage due the lossy compression. I am certainly not suggesting repeated saving of JPG files with the same parameters is a good thing, but only that there are even worse ways to do it.

JPEG Lossless Rotation

Sometimes for viewing, we need to rotate an image beween horizontal or vertical (Landscape or Portrait), without needing any other editing operations. But if you save that rotated image as JPG, that is another SAVE operation and additional JPG artifacts. But there are image programs that can rotate a JPG file image exactly 90 or 180 degrees, and then save it again without additional loss, by rotating it without uncompressing and recompressing it first, thus preventing any additional JPG artifacts. This option merely rearranges the row and column data, without uncompressing that data. So while the JPG file itself is still lossy, the lossless rotation does not create additional artifacts. Jpegclub.org has a list of programs that support this lossless rotation feature. Standard photo editor programs typically do not provide this option, but a few of the better known programs that can do this are IrfanView Free, Windows GraphicConverter Trial available, Macintosh ThumbsPlus Trial available, Windows IrfranView needs its free extra JPG plugin package to provide lossless rotation, which is then found at menu Options - Lossless JPG Operations when the JPG file is open. Irfanview also shows the JPG EXIF information well (Exchangeable Image File Format) - extra file data added by cameras showing information like camera name, date, f-stop, shutter speed, exposure compensation, metering and flash used, etc.
More Preaching, but it is important

JPG format has a magic status for us. JPG is wonderful when the purpose is right, but we need to understand we pay a cost in quality. I know you surely will consider using JPG for master copies, everyone does at first, because the JPG file is so small, and the idea is frightfully appealing. But it's a high price paid in lost quality, and you will eventually come around to appreciate the quality of TIF files. I hope that happens before you have damaged important images that you cannot scan again. Some people argue that high quality JPG masters are not so bad. That's OK with me, it's your file, but the file size is one property of an image, and quality is another. You can choose either way, and I hope you choose Highest Quality, at least for your master copies. My goal is that you understand the effects of your choice in regard to your valuable master copies. If you simply must use JPG for your master copy (if file size is the most important property of this image), then at least use the best Quality you can. Aim for a average JPG file size at least as large as 25% of its true memory size. For web images, file size is indeed important, and absolute quality is less important, and a JPG file size 10% of uncompressed size is often a good tradeoff of quality for size for color images, but that is too extreme for any notion of a master copy. Grayscale images do not compress as much as color at the same settings. Grayscale is already 1/3 the size of color, and grayscale JPG files won't compress as much.

Then keep a master copy that you never rewrite. For any purpose, always start with a copy of that JPG master and never modify that JPG master itself. Saving that JPG master image again causes more artifacts, even more loss, permanent loss, so simply don't do it. If you simply need to rotate to vertical, or to scale for printing, consider not saving that simple change at all if it is trivial to do again. Save any change to a different file, and never make your one master copy worse. Or save the change to a TIF file, so as to not create more JPG artifacts. You could of course just use a TIF master instead, and sleep better at night. And be aware that lowering scan resolution to reasonable values for the purpose is often the best size reduction you can make. Judge your own common sense periodically. Why can't we see that a decent JPG image compressed to be only 25% of original size (1/4 size, still amazingly small, and still with mild artifacts), is more useful, and a much better deal, than one at 5% size that is simply too awful to use? I know, the macho types are saying "but I can get it down to 3%". Then go for it man! <grin> For emailing and for web pages, JPG file format is the smallest by far, and the best goal by far (for photo images). JPG is acceptable for such read-only "viewing" use, and a JPG copy normally is used for such purposes. JPG is NOT very acceptable for "editing" use, when you may need to edit and save the image again (we always do). JPG is best only for photographic images. For line art and graphic files (characterized by containing graphic sharp edges and very few but solid colors), then TIF LZW or PNG is good, or GIF files too, which have historically been used for graphics on web pages. The process of saving a JPG file to disk first compresses the image data to make the file be much smaller. This JPG compression affects the image quality, because JPG compression uses a very different technique than does PKZIP or TIF LZW or PNG file compression (lossy vs. lossless). JPG compression is extremely effective, because it does not attempt to be 100% faithful to the original image data. If parts of the image data are a problem for it, the JPG compression simply modifies that data to make it conform better. That means when we read that JPG file later, we don't get back the same original image data (that is the meaning of lossy, losses of image quality). Also the software opening that JPG image does a similar thing when it reads it. It does not necessarily show exactly what is in the file, it can also take similar liberties. Web browsers for example are not the best JPG image viewers, but they are the fastest JPG viewers. Every time we save a JPG file (menu FILE - SAVE AS - JPG), it compresses again, and image quality is lost. This loss is variable, depending on the JPG Quality factor used, but it is never zero. If we edit the JPG file image and save it again, then quality is lost again. Even if we save it at a much higher quality setting the second time, it is still a second compression and another loss. Every time we compress a JPG file, we add more JPG artifacts and lose a little more quality. Artifacts are always a one way trip, there is no recovery. The damage is done. Most other file formats (say TIF or PNG) use lossless compression. These files are larger than JPG because they use milder, fully recoverable (lossless) compression to carefully preserve all of the original image data. These file formats remain full quality at all times, no matter how many times we might save them to a file, which is of course exactly what is needed for a master copy.

The small JPG file size is great, but it has a big price of reduced quality. There are proper times and places one would use it, and also major reasons one would not. There's nothing wrong with creating a JPG image using a moderate to high Quality factor to put a photo image on a web page or to send it via email. It's the only practical way. However there is an additional quality loss when we try to edit and save that JPG file a second time, so JPG is usually inappropriate for important archived master copies. The risk if you make this mistake now is that you cannot undo it in the future, so now is the best time to understand the situation. See the very worthwhile JPG FAQ by Tom Lane Progressive JPG is a web option that quickly shows the entire image in very low quality, and the quality fills in and improves as the file download completes.
JPEG 2000

A new JPEG 2000 file format is available now in many newer program versions, with various file extensions, normally .jp2 (or .jpx, with option extensions). JPEG 2000 uses a wavelet compression method. It has a lossless option (to perhaps 65% size). Otherwise it is lossy, size comparable to regular JPG files, but different... slower then JPG, but arguably perhaps better quality. Extremes of compression have few detectable artifacts, however JPEG 2000 images become noticeably soft with greater compression. Paint Shop Pro 8 and PhotoImpact 8 started including JPEG 2000. Adobe Elements 3.0 includes JPEG 2000. Elements 2.0 has an update to add JPEG 2000 - at the How To palette, Select a Recipe, Download New Adobe Recipes, then (very important) the BACK button, and you will see it. Photoshop has an optional JPEG 2000 plugin from CD, see JPEG 2000 at the CS or CS2 Help menu. Note that web browsers do NOT support JPEG 2000 yet, and so compatibility is still a very significant issue. Therefore it seems important to stay with the original JPG format for now, at least if you want others to be able to open your files.
Graphic Interchange Format (GIF)

(.GIF file extension) There have been raging debates about the pronunciation. The designers of GIF say it is correctly pronounced to sound like Jiff. But that seems counter-intuitive, and up in my hills, we say it sounding like Gift (without the t). GIF was developed by CompuServe to show images online (in 1987 for 8 bit video boards, before JPG and 24 bit color was in use). GIF uses indexed color (next page), which is limited to a palette of only 256 colors. GIF was a great match for the old 8 bit 256 color video boards, but is inappropriate for today's 24 bit photo images. GIF files do NOT store the image's scaled resolution ppi number, so scaling is necessary every time one is printed. This is of no importance for screen or web images. GIF file format was designed for CompuServe screens, and screens don't use ppi for any purpose. Our printers didn't

print images in 1987, so it was useless information, and CompuServe simply didn't bother to store the printing resolution in GIF files. GIF is still an excellent format for graphics, and this is its purpose today, especially on the web. Graphic images (like logos or dialog boxes) use few colors. Being limited to 256 colors is not important for a 3 color logo. A 16 color GIF is a very small file, much smaller, and more clear than any JPG, and ideal for graphics on the web. Graphics generally use solid colors instead of graduated shades, which limits their color count drastically, which is ideal for GIF's indexed color. GIF uses lossless LZW compression for relatively small file size, as compared to uncompressed data. GIF files offer optimum compression (smallest files) for solid color graphics, because objects of one exact color compress very efficiently in LZW. The LZW compression is lossless, but of course the conversion to only 256 colors may be a great loss. JPG is much better for 24 bit photographic images on the web. For those continuous tone images, the JPG file is also very much smaller (although lossy). But for graphics, GIF files will be smaller, and better quality, and (assuming no dithering) pure and clear without JPG artifacts. If GIF is used for continuous tone photo images, the limited color can be poor, and the 256 color file is quite large as compared to JPG compression, even though it is 8 bit data instead of 24 bits. Photos might typically contain 100,000 different color values, so the image quality of photos is normally rather poor when limited to 256 colors. 24 bit JPG is a much better choice today. The GIF format may not even be offered as a save choice until you have reduced the image to 256 colors or less. So for graphic art or screen captures or line art, GIF is the format of choice for graphic images on the web. Images like a company logo or screen shots of a dialog box should be reduced to 16 colors if possible and saved as a GIF for smallest size on the web. A complex graphics image that may look bad at 16 colors might look very good at say 48 colors (or it may require 256 colors if photo-like). But often 16 colors is fine for graphics, with the significance that the fewer number of colors, the smaller the file, which is extremely important for web pages. GIF optionally offers transparent backgrounds, where one palette color is declared transparent, so that the background can show through it. The GIF File - Save As dialog box usually has an Option Button to specify which one GIF palette index color is to be transparent. Interlacing is an option that quickly shows the entire image in low quality, and the quality sharpens as the file download completes. Good for web images, but it makes the file slightly larger. GIF files use a palette of indexed colors, and if you thought 24 bit RGB color was kinda complicated, then you ain't seen ' yet (next page). For GIF files, a 24 bit RGB image requires conversion to indexed color. More specifically, this means conversion to 256 colors, or less. Indexed Color can only have 256 colors maximum. There are however selections of different ways to convert to 256 colors.

Indexed Color and Palettes

What's an Index? What's a Palette? This topic of Indexed Color is NOT unique to GIF. TIF and PNG files can save Indexed color too, but GIF requires it, GIF has no other mode. We speak of GIF files here, but it could be TIF or PNG too. File formats like TIF and JPG store a 24 bit RGB value for each of the millions of image pixels. But GIF files only store a 4 or 8 bit index at each pixel, so that the image data is 1/6 or 1/3 the size of 24 bits. Indexed Color is limited to 256 colors, which can be any 256 from the set of 16.7 million 24 bit colors. Each color used is a 24 bit RGB value. Each such image file contains its own color palette, which is a list of the selected 256 colors (or 16 colors in a smaller palette). Images are called indexed color because the actual image color data for each pixel is the index into this palette. Each pixel's data is a number that specifies one of the palette colors, like maybe "color number 82", where 82 is the index into the palette, the 82nd color in the palette list of colors. We have to go to the palette to see what color is there. The palette is stored in the file with the image. The index is typically a 4 bit value (16 colors in palette) or 8 bit value (256 colors in palette) for each pixel, the idea being that this is much smaller than storing 24 bits for every pixel. But an 8 bit number can only contain a numerical value of 0 to 255, so only 256 colors can be in the palette of possible colors. The size of most graphics files can be limited to use 16 colors, which only uses 4 bit indexes, making the file smaller yet, half the 8 bit size for the index for each pixel. Not that the graphics may appear to have only say four colors, but any sharp edges (like say on text characters) are aliased, adding a few new intermediate shades of the colors, blending the edges so that the jaggies don't show. So if you count four colors, assume 8 or 16 colors will make it look better. The file also contains the palette too, which is the table of the selected 24 bit colors, or 3 bytes of RGB overhead for each color in the palette (768 bytes for 256 colors). The first RGB color in the table is index 0, the second RGB color is index 1, etc. There can be at most only 256 colors in the palette. So indexed files have 24 bits stored for each palette color, but not for each pixel. Each pixel only stores either a 4 bit or 8 bit index to specify which palette color is used. Of course, in comparison, a 24-bit RGB image would store 24 bits RGB for each pixel (3x more size than 8 bit indexed), but without the 256-color 24-bit palette (only 768 bytes). But JPG compression can reduce this file size substantially, and 24-bit RGB can show 16.7 million colors, instead of only 256 colors. So, GIF would not be used for color photo images today.

Image programs will show the palette for indexed images, and can modify palette colors. There are various ways to create the palette, to choose the possible color choices that it will contain. This palette choice affects the image greatly.
Converting to 16 or 256 colors

There are several ways to convert to indexed color. Two choices are required, to specify a palette of colors, and also a choice how to dither or show colors not in that limited palette. The dithering choices might be: Dithering - Dithering means representing a color by combinations of dots of other colors. Dots is pretty much the definition. If the one exact shade of pink is not in the palette, then dots of other palette colors are mixed to simulate the color. Dithering often causes a visible and objectionable dotted or speckled image. But that simulated color may be much closer than a nearest color approximation. Nearest Color - This selection is the same as disabling dithering, or no dots. If the exact shade of pink is not in the palette, then the closest color in the palette is used, which might not be very pink at all. Sometimes exact color is not important. No dithering means no visible dots. Choices for a palette often have many names, but are of two main types, Standard or Adaptive: Adaptive or Optimized or Perceptual Palette These custom palettes are created from the 256 most representative colors within the one specific current image. The gradient image below is red graduated to white, originally over 5000 shades of pink and white. It is pretty much all red.

The PhotoImpact optimized palette at right for this image includes 8 system colors, including black, but this palette specifically has 248 shades of pink to be appropriate for this specific image. That is enough shades of pink that the quality of the GIF image does not show any banding or dithering in this easy case (one color). However only 256 colors is often pretty bad for normal photos (too few indexed colors for photos, which typically need up to maybe 100,000 colors, not 256). Since most colors in this graphic image are red, this optimized palette appropriately contains mostly red, so it is a much easier case than a normal photo. Optimized and Adaptive (two words for same thing) means optimized for the specific image, instead of being optimized for the old Windows 8 bit Palette Manager (next below). Standard Web Browser Palette The Standard Palette (often called the Netscape palette or Web palette) always contains the same colors for any image. It is sometimes called 6-6-6, because it contains six standard evenly spaced colors for each of Red, Green, and Blue. Those 6x6x6 color combinations create 6x6x6 = 216

standard color combinations, which are independent of any specific image (used for any image). The remaining 40 colors are standard colors reserved for the Windows or Macintosh desktop. The Standard Palette always contains combinations of the following 6 tones for each of the Red, Green, Blue primaries:
6 colors, Hexadecimal (0-ff) 6 colors, Decimal (0-255)

00

33

66

99

CC

FF

51

102

153

204

255

The 216 combinations of these 18 colors above (six shades of the three RGB colors, 6x6x6 = 216) produce the Standard web-safe palette below (this one is the standard "Web" palette from Elements 2.0) The 6x6x6 standard colors are intended to be somewhat suitable for ANY generic image, but of course, it is not correct (not precise) for any normal image. For example, this very GIF image uses that same palette, and notice that 6 shades of blue are insufficient to show the Title bar without banding. This standard palette was very important for old 8 bit video cards. The situation used to be (in historic times, ten years ago) that 8 bit video card drivers had only one Windows video Palette Manager, requiring ALL images on that desktop to share ONE palette simultaneously. We used to see bizarre psychedelic colors when the palette of a new image reloaded that palette and affected all other images on the desktop. Perhaps palette Index 82 changed from pink to green, correct for the one image, but very wrong for all other images on the desktop. When the WWW started showing web pages with multiple images on the one web page, it was awful. Netscape standardized the 216 color palette as a workaround. Using one standard palette for all GIF images was better than the alternative, even if that generic palette was far from optimum for any image. This standard 216 color palette is that palette, one generic palette for all indexed images, even if not best for any image. But this concept of a Standard Palette or web-safe palette is obsolete today, now that we all have 24 bit video cards. Today, using the Standard Netscape 216 color web-safe palette only helps those still using ancient 8 bit video cards. Using the standard 216 colors means old 8 bit video systems can show them without adding additional dithering (dotted color). This used to be important several years ago when we all had 8 bit video boards. There are two schools of thought about this 1) the belief that this might somehow still be important, and 2) why bother anymore? Why be artificially limited for no current reason? My opinion is that the so-called web-safe palette is an obsolete concept, no longer useful today, and is instead outright detrimental today. There is no Windows Palette Manager anymore (except in drivers for obsolete 8 bit video boards). Today's 24 bit video boards can show any possible

palette color, even when in 256 color mode (easy to test). We don't see dithered colors (speckled dotted colors) in 256 color mode anymore, unless the images were created that way in the first place by using a so-called web-safe palette. The GIF problems today are mostly all self-inflicted due to still trying to be limited to obsolete concepts (the use of non-optimum palettes). There is no magic in 216 colors on today's computers with 24 bit video. Adaptive palettes (instead of web-safe 216 color palettes) give better images, and makes creating poor images unnecessary in indexed color. A non-dithered Adaptive palette is hard to beat. Most of the GIF graphic images on this site (screen captured dialogs, etc) use a 16 color Adaptive palette from Nearest Color. The exact shade of color was not very important, but the small file size for the web was important (however where there was embedded photo content of many colors, the image may have been sliced, mostly GIF portions with a little JPG portion). The few users still using ten year old 8 bit boards, if any, are frankly used to poor color, it's nothing they haven't seen before, and they can upgrade if they wish. Why make the overwhelming majority, those with the now standard 24 bit boards capable of good color, see poor color because it used to be that not everyone could? Personally, I ignore web-safe today, and I go out of my way to use the optimized or adaptive palettes for GIF files. The images are much better, without dithering dots to ruin them. For the other side of it, Microsoft has a good write-up about Safety Palettes, about dithering and the standard 216 color web-safe browser palette. Note it is dated 1996, and it was still important then, but modern 24 bit video cards have changed the world now.

A little more, to be sure you understand Adaptive palettes: GIF, particularly 16 color GIF, is ideal for web pages for logos and similar simple graphics without continuous tones. The files can be very small (assuming solid color graphics).

The next example shows how a 16 color GIF file with Adaptive palette can be better than a 256 color GIF file with Standard palette. The 16 color Optimized GIF file enlarged 4 times, and its palette.

OK, it's a special case, but since most of this image's colors are red, the optimized palette contains mostly red also. Since we only have 16 colors, and since 16 colors is insufficient for this graduated image, then many of the pinks are combined into the same few colors, and we see some dots (pixels, this is shown at 4x size).

In the image below with the Standard palette (above was Adaptive Palette), we do have the standard 216 colors available, but very few of them are the Reds that we need for THIS image, so the results are not even as good as the 16 color Optimized palette in this case.

This graduated image was ill-suited for 16 colors, but 16 colors of Red is still more than 6 colors of Red. This graduated image would be better as a 256 color GIF, or a JPG. The JPG file would be smaller, but not likely better than 256 color Adaptive in THIS case, because 24 bit color only has 256 shades of Red too, and red is about all we need here. Most graphics (logos, dialog boxes, etc) don't have more than 16 colors anyway. In those cases, 16 bit GIF files can be much smaller than 256 color GIF files.

Memory problems
Large color images consume a lot of memory, and the memory requirements increase exponentially with the square of the resolution used. The Video Resolution Basics section was about computing image memory requirements. And that's not nearly all of it either. If your image uses 4 layers, then you have 4 large images in memory. Editors must also retain multiple copies of the image to implement the Undo/Redo History function. Some programs have more efficient ways to store only the changed area of the image instead of the entire previous image, but some only offer one level of Undo/Redo, because Undo is expensive in terms of memory. Some programs can be configured to retain a fewer number of Undo levels, and a smaller number, perhaps 6 or 10 levels instead of 100 Undo levels, may realistically be more appropriate. And descreen filters for moir can use outrageous amounts of memory too. Minimal new computers are shipping with 128 MB of system memory now, but a film scanner really wants 256 MB. You will need 256 MB with Windows XP too, and 512 MB is better for large images. Memory is inexpensive now, more can make a noticeable difference in performance, and it is the best upgrade you can do if you use large images.
Why is memory size important?

Handling many megabytes of images can be difficult. The computer needs memory for
1. the image(s) 2. the program(s) 3. the operating system

all in memory at one time. If memory size is insufficient to hold all of this, then the excess bytes that cannot fit in memory (those bytes we don't need at this instant) are temporarily saved in the swap file, called swapping. The swap file is a huge file on hard disk to hold memory bytes that will not fit in memory, until they are needed again (file WIN386.SWP in Win9x, PAGEFILE.SYS in WinXP).
What is swapping?

There are two disk I/O operations when swapping; the "write" to save some unneeded bytes to make room in memory, then the "read" to get the needed bytes back into memory. An active program often needs those bytes back again in only milliseconds, but they still won't fit, so then other bytes must first be saved on disk to make room. Then the first bytes are read from disk back into memory. The entire process may be repeated thousands of times, over and over. This is swapping the unneeded bytes out of memory for those bytes needed back from the disk swap file, back and forth, over and over. But disk access is extremely slow compared to memory access In moderation, swapping is a wonderful magical feature, allowing operations that we could not otherwise do with the memory we have. But in extreme cases when the disk access LED is always on, our swap file works incessantly, never stops, and our computer is brought to its knees. A more technical comment about the swapping mechanism: Not every portion of every program is needed at any given moment, technically only one word is accessed at any instant. Windows can move the least-recently-used blocks of memory to the swap file on disk in 4K byte blocks, called "pages" (Windows 3.1 used larger blocks called segments, up to 64K, more an "all or nothing" concept). Swapping is more technically named paging. Paging uses a protected-mode CPU trap mechanism that is similar to a GPF (General Protection Fault). Typically a GPF is a fault when an errant program wildly attempts to access protected memory that it has not reserved, memory that it does not "own" (the program is usually the culprit, but it might be the victim of another program). Similarly, when a program properly accesses valid memory, but which is not currently present in physical RAM, it causes a CPU "page fault" instead. There is a memory driver (fault handler) that recognizes that this memory only needs to be read back in from the swap file, and can correct the condition by swapping, instead of terminating the program and reporting the fault to the user. Most faults are fatal, but page faults are typically correctable. The Windows System Monitor will report a few statistics about page faults, page ins, page outs, etc. A little swapping is very normal.
What is Virtual Memory?

The hard disk is an important part of the memory system, in the form of the Swap File. The swap file on disk is called Virtual Memory. The swap file holds the allocated memory bytes that will not currently fit into physical RAM memory. The disk is very slow in comparison to physical memory, but we are not "out of memory" until the disk is full. When the disk is full, we are out of memory. The swap file is a wonderful invention for occasional use, until we reach the practical limit and start slow incessant swapping.

Windows provides a dynamic swap file size. It's Maximum size setting should be ALL of the room remaining on the disk (the default.). It is pointless to limit it smaller, it does not save anything, because only the Minimum is initially allocated (and that Minimum should be made large enough to satisfy all normal requirements). So the Maximum is not even used until it is needed, but when it is needed, there is no alternative. Limiting the maximum file to less than the available disk space risks crashing sooner if and when that file fills. What's the advantage of that? In earlier days, Windows 3.1 did offer a "permanent" file setting for efficiency (couldn't grow), but this is no longer appropriate for Win9x or XP. A large Minimum also does this for the general case. Windows says, "let us handle it", and it should do just fine in that regard. The concepts of virtual memory and paging in the Unix core of Macintosh OS X are very much the same. This is simply how modern multi-tasking computers must work. You must provide ample free disk space for the swap file to grow. When your disk fills so that the swap file cannot grow, you will get "Out of memory" errors. Depending on how smart the software, you may get a system message about the swap file, or you may get a program error about "Out of memory", but either way, your disk is full. It probably has too many huge images on it. Empty your Recycle Bin and Temp folder (see Start - Programs - Accessories - System Tools - Disk Cleanup, in Win98, ME and XP). If your machine is reduced to a slow crawl while the disk access LED is incessantly active, then the cause is clearly due to swapping, because you are trying to use more memory than you have. Memory unused at this instant in time has to be saved to disk swap file to make room for the bytes needed NOW in real memory. In only a few milliseconds however, your software may need the first bytes again, and so new bytes must be written to disk file to make room to read the first bytes back into memory from disk file again. This may be repeated jillions of times. In excess, this swapping is painfully slow. It's the proverbial 10 pounds of potatoes in the 5 pound sack.
Swap file, memory, and disk cache memory usage

In Windows XP, CTRL-ALT-DEL shows the Task Manager, which has a tab for Performance. It shows installed Physical memory as Total, with Available and System Cache (disk cache memory). Available plus System Cache adds to more than Total, the additional memory is in the Page File (least used stuff swapped to disk). The PageFile Usage (PF) is shown at Commit Charge, with current swap size being show as Total (divide by 1024 to get graphed value in MB). PF Peak history and Limit (limited by free disk space) are also shown. In Windows 9x, use the menu Start - Accessories - System Tools - System Monitor. If you don't find the Monitor, then it was not installed originally. Go to Control Panel - Add/Remove Programs - Windows Setup - Accessories - Details, and select System Monitor, and install from the Windows CD. If you have not used the 9x Windows System Monitor before, use its menu Edit - Add Item Memory Manager to add these values to watch:

Allocated Memory

Swap File Size

Unused Memory

Swap File In Use

Swappable Memory

Disk Cache Size

Maximum Disk Cache

These instantaneous values can be displayed as graphs in the 9x System Monitor, and will show you the real time size of your Swap File and Disk Cache. You can watch it while scanning. As Allocated Memory increases (memory in use), Free Memory decreases (memory available). When Free Memory approaches zero, then the Swap File In Use begins to grow, the disk activity peaks, and the machine slows greatly while waiting on the disk drive. A little swapping is very normal, but a lot is painful. Clicking one of the graphs causes its actual numeric value to show on the Monitor's lower status bar.
Memory Workarounds:

One immediate solution is to reduce your scanning resolution drastically, to more reasonable values for the purpose. Smaller images use less memory, it's simple as that. This is imminently practical in many cases (if scanning at 9600 ppi, see page 48 about requirements). While scanning, do terminate all other programs not related to scanning, especially internet and Office programs, everything big, everything not essential. This of course makes their memory available. There is not enough memory to run everything at once with the scanner, unless you're a real glutton for pain (no sympathy if it is your own fault <grin> If the main disk is full, but you have another disk partition with space, then you can move your swap file to the partition with more free space, using the Windows Control PanelSystem-Performance-Virtual Memory. This space won't help speed, but it may prevent total failure. Make more room on your disk. Empty your Windows Recycle Bin. Empty your Temp folder. Empty your browser's temporary internet files. Windows menu Start - Programs Accessories - SystemTools - Disk Cleanup will do all of this periodic cleanup effort. Use it now and then. The only real solution for insufficient memory (excessive swapping) is to add memory.

At least 128 megabytes is extremely desirable for a scanner and Win9x, and more for a film scanner. At least 256 MB for WinXP. A good rule of thumb for good performance is those numbers for the system, PLUS additional memory of at least three times the size of the largest image that will be processed. 512 MB is NOT at all unreasonable today for XP and a film

scanner. Since memory is so cheap now, I have 640 MB for XP and a film scanner. Older computers (Pentium I or earlier) had memory cache limitations, but since then, motherboard capacity is the only limitation. Remember when memory was $40 per MB? It's currently only a few cents per MB, and there's really no reason to suffer anymore. Adding memory is the best one single thing you can do to improve your computer, especially for a film scanner.

Potrebbero piacerti anche