[Ham-Computers] Digital Image Formats - loooong

Hsu, Aaron [email protected]
Fri, 14 Nov 2003 18:33:19 -0800


-----Original Message-----

What might be most helpful to many list subscribers, is for one of you photo
and/or scanner wizards to explain what type of image (.bmp, .gif, .jpg etc)
should be used for what and when, when to use compression - how much to use
-
when not to use it at all, the right resolution setting - 300 pi, 150 pi, 75
pi
etc. 	
	
Duane W8DBF	
   
----------

OK, here's a relatively brief synopsis of the common ones...

BMP - BitMaP format.  The image is literally stored as a memory bitmap - 1
bit per pixel and X number of color bits per pixel.  So a 1024x768x24-bit
color image will take about 2.4MB of space (1024x768x24-bits divided
8-bits-per-byte).  The "original" graphics format used by the Windows
platform and that's why it's so prevalent.  

TIF or TIFF - Tagged Image File Format - The "preferred" format used for
archive files and press publishing.  It's a "raw" image format where each
pixel is represented by 1 bit and it's associated color information bits
(8-bits per color is the norm).  There are various minor "flavors" of the
TIFF format, but the most common (and compatible) is the original format
with no compression (I believe it was a Macintosh format).  Most programs
today can read both PC or MAC "byte-order" TIFFs as well as TIFFs with LZW
lossless compression.  Other flavors are not as well supported.
WARNING...TIFFs can also use JPEG compression...not generally recommended.
See below about JPG.

GIF - Graphics Interchange Format - originally developed by CompuServe (and
released to the public domain) as a way to share files in the Photo and
Graphics forums.  It is an 8-bit format, so color depth is limited to 256
colors.  Was perfect at the time it was created as EGA was the hi-res
standard of the time (640x350x64).  It uses lossless compression, but the
space savings is minimal.  It's gone through some revisions since it's
original inception, but GIF-87a and GIF-89 are the most widely used formats.
Animated GIF's are commonly used on webpages (all those animated icons are
GIF's).  There's a long standing debate as to how it's pronounced...with a
"J" sound like Jiffy or with a hard "G" sound like Graphics.

PNG - Portable Network Graphic - new format developed by CompuServe when
they realized that they lost a lot of potential royalty money when they
"gave away" the GIF format to public domain.  Original intent was to have
users replace all GIF's with PNG's and charge a royalty fee on any viewer
programs.  Technically better than JPG since it uses lossless compression.
But, due to the need to license (aka "pay for") any program that creates the
format, it's not widely accepted - especially since JPG is free.

PSD - PhotoShop Document - A good alternative to TIFF though not as widely
supported.  Since Photoshop is *the* image editing program of choice, the
format is widely used.  The advantage of PSD over TIFF is that Photoshop
specific command and file information is saved with the image (e.g. layers).
This allows one more flexibility when saving and re-editing the image at a
future time.  It's a non-compressed format and since it saves some editing
info, the filesize may be larger than the "raw" image.

RAW - RAW is the name given to the datastream that comes out of the CCD
sensor of a digital camera.  Much like TIFF, it's preferred by professionals
as the image is exactly the way the camera saw it - without any color
balancing, sharpening, adjusting, etc the camera's firmware might add.  Only
high-end digital cameras allow saves in RAW format (e.g. the NEF format on
hi-end Nikons).  On a digital camera that supports RAW and TIFF, the only
difference is the fact that the TIFF format is saved by the camera's
firmware (after image adjustments) whereas the RAW data is saved directly
"as is".  This gives the pro the ability to "fine tune" the image exactly
they way he/she wants by using the editing tools of an image editing program
(such as Photoshop) rather than letting the camera do the adjustments.

JPG or JPEG - Joint Pictures Experts Group - a format created by the JPEG
group as a way to distribute pictures and save space.  It's now the most
common photo format used, but it's also the most easy to mis-use/abuse as it
incorporates lossy compression.  Not commonly used by "professionals" as
it's not possible to turn off compression.  The more you compress the image,
the "blockier" aka "aliased" the picture will look when the file is
de-compressed and viewed.  Opening a JPG and re-saving the file will
re-compress the file and cause more loss.  Much akin to multi-generation
audio tape copies.  As such, it's not a good idea to save photos in .JPG
format unless one is absolutely sure that photo doesn't need to be edited
and re-saved.  My previous post gave some hints on how to create and save a
"decent" JPG file.  Another thing to keep in mind...when a JPG file is
un-compressed for viewing/editing, it is "full-sized" in memory.

So let's say I scan an image at 1024x768 in 24-bit color.  The "raw" size of
the scan/photo is roughly 2.4MB in size.  When I save it in JPG format at
100% quality (aka minimum compression), the resulting filesize is about 550K
(notice the 4:1 compression even at "100%" quality or lowest compression).
If I re-open the image, the amount of memory it takes up is still 2.4MB as
the image is decompressed when it is read.  However, the image quality isn't
as high as when I first scanned it since we lost some pixels when it was
first compressed and saved.  If I really zoom in on the picture, minor
details will be gone - most noticeable in fine textures such as hair
(individual strands may not be there anymore).  If I re-save this file again
at 100%, the resulting filesize is still about 550K, but more detail is now
lost as the file is once again compressed.  Ad infinitum.  

A worse example is to take the same 1024x768 scan and then do the first save
at 75% quality (roughly 20:1 compression).  The filesize is now about 130K.
I open the file and it expands to use 2.4MB RAM (decompressed).  I look at
the file and notice the lower image quality due to compression.  I do some
editing and re-save the file.  Here's the hitch...if I save it again at 75%
quality, the filesize will still be about 130K, but the resulting image
quality is reduced again from the original image due to compression.
However, if I decide to save at 100% quality, the new file will be 550K in
size (note the larger file), but the resulting quality is still lower than
when I first saved it at 75% quality.  Why?  Remember, the second save is
still compressed.  I've now first saved at a 20:1 ratio, then saved again at
a 4:1 ratio.  The image quality suffers because the compression artifacts
are cumulative.  The second file is larger since the ratios are vs. the
"raw" image size of 2.4MB.  The second save was compressed a total of 2
times and the third time I open it, I'll notice the image quality
degradation.  Thus the caveat of using lossy formats such as .JPG.

Additional notes - some formats allow "header" information.  The header
contains additional information about the image.  Think of it as "comment
space".  Common header info includes size, resolution, creator, "destined"
output, program specific information (layers), etc.  TIFF and JPG have
headers.  Another info format known as EXIF is now available in digital
cameras.  This info includes time/date, F-stop, aperture, shutter speed,
color balance, and additional information about how the camera was set when
the picture was taken.  This data is embedded into the JPG format as extra
bits that most programs ignore.  A program that supports EXIF will read the
extra bits and regenerate the EXIF data.  If you re-save a JPG that has EXIF
data, it will only re-write the EXIF data if it supports EXIF (remember, JPG
saves always re-compress the data and this will eliminate the original EXIF
data).  Programs that don't support EXIF will destroy the EXIF data if the
image is re-saved.

As for which format to use for what purpose?  It depends.  JPG works for
most people as long as they realize the caveats involved (noted above).
Unfortunately, most people don't.  The absolute preferred format for
"archives" is TIFF or PSD.  I usually use PSD for "work in progress" and
TIFF with LZW compression for archives.  If you're scanning a picture to
send in e-mail, then JPG is just fine.  If you're using a Windows platform
and need to send an image to someone who doesn't have an image editor/viewer
installed, then BMP would work (although the filesize would be large).

As for what dpi to use.  The old rule of thumb was to use the Nyquist
theorem - for digital images, twice the DPI of the output device.  Old
output devices (aka dot-matrix printers) were about 96dpi, so you would scan
at 200dpi.  Today, with pseudo 2880dpi resolution, the Nyquest number no
longer applies.  The human eye can't really tell the difference past 300dpi,
so 300dpi scans are suitable for most purposes.  Professional press printers
use 1200dpi to 2400dpi for commercial work, but that's overkill for the
typical home user.  If the destination is for viewing on-screen only, then
scanning at 72dpi should work fine.  But scanning full size at 150dpi
(Nyquist) and then resizing the image to 800x600 will produce better
results.  I still scan the original at 300dpi and then reduce to 800x600,
but that's just me.

As for compression..."less is more".  The less you compress, the better the
image quality (for lossy formats).  Pros won't even touch lossless
compression for fear of image corruption.  For e-mailing a JPG photo at
800x600, use a 75% quality setting (20:1 compression) - the resulting image
will look fine on-screen.  If e-mailing a photo for printing, then scan at
300dpi and then use a higher compression level (e.g. 40% quality).  Yes, it
sounds like it'll look crappy, but since you had much more information in
the picture to work with, the resulting highly-compressed file will still
have a lot of information to rebuild the image from when de-compressed.
And, the resulting filesize will be roughly the same as a lower dpi scan
with lower compression.  Another option is to scan at 300dpi, resize the
image to a 2-megapixel format (1600x1200) and save as JPG at 100% quality
(this is equivalent to the "Fine" mode on most 2-megapixel cameras).  In
this format, it'll print a great 4x5.33" native size photo, good upto 5x7,
decent at 8x10, and the filesize will be around 850K.


So, here are some recommendations...YMMV.

Cherished photo to save - 300dpi (or even 600dpi) scan, save in TIF or PSD
(with lossless compression, if desired).  BEWARE!  Large file sizes
encountered!  A full 24-bit 8x10 @ 300dpi scan will result in an 21.6MB
file!  If you don't have the drive space and must use JPG, then save with
100% quality - this will reduce the filesize 4:1 (about 5MB) and minimize
the loss.  You can also try TIFF with LZW for better quality, but the
filesize reduction is not that great.

Image to e-mail and/or view on screen - 150dpi scan, resize to 800x600 (or
close - keep aspect ratio), save as JPG with moderate compression (about 50%
to 60% quality).  Printing may result in moderate aliasing (blockiness).

Image to e-mail and print - 300dpi scan, resize to 1600x1200 (or close -
keep aspect ratio), save as JPG with light compression (100% quality).

Image to print "full size", maybe re-size and e-mail, but not archive -
300dpi scan, retouch as needed, print.  Save in JPG with moderate to high
compression (30% to 50% quality) to save drive space.  The saved format can
then also be resized smaller, if needed, for e-mailing.  Not recommended for
permanent archives (see above)


Are we thoroughly confused yet?  Don't worry, it's a confusing subject and
most people aren't familiar with the intricacies of digital imaging.  All I
know is that I know enough to know I'm definitely *not* an expert!  If
anyone has further questions, please feel free to ask.

73,
  - Aaron Hsu, NN6O



--- StripMime Report -- processed MIME parts ---
multipart/mixed
  multipart/alternative
    text/plain (text body -- kept)
    text/html
The reason this message is shown is because the post was in HTML
or had an attachment.  Attachments are not allowed.  To learn how
to post in Plain-Text go to: http://www.expita.com/nomime.html  ---