Here are some file formats you may have seen before. They have one thing in common: they don't belong on the Web. Before we go into these "leftover" formats, let's summarize why the three formats we've talked about so far are good to use on the Web.
Not Microsoft Windows, X Windows, a basic windowing system used mostly on Unix machines. There's a file format invented for X Windows graphics, and occasionally you'll see files in that format on the web.
If you ever wanted to find the worst graphics file format for the Web, you need look no further. XBM, used for black and white images, and XPM, used for colored images, not only don't have any compression, they're *text* files. It's true. Here's an XBM file:
#define question_width 20
#define question_height 23
static char question_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0x07, 0x01, 0x00, 0x0c, 0x81, 0x0f, 0x0c, 0x41, 0x18, 0x0c,
0x21, 0x33, 0x0c, 0xa1, 0x25, 0x0c, 0xc1, 0x24, 0x0c, 0x01, 0x32, 0x0c,
0x01, 0x19, 0x0c, 0x81, 0x0c, 0x0c, 0x81, 0x06, 0x0c, 0x01, 0x07, 0x0c,
0x01, 0x07, 0x0c, 0x81, 0x0c, 0x0c, 0x81, 0x0e, 0x0c, 0x01, 0x07, 0x0c,
0x01, 0x00, 0x0c, 0xff, 0xff, 0x0f, 0xfe, 0xff, 0x0f};
That isn't a dump of an XBM file or a program that generates an XBM file, that's the file! Plain text. If you copy and paste that into a file called "whatever.xbm" (start with the first "#" and end with the ";") and save it on your desktop, you can bring up your favorite web browser and drag that file into the browser window, and the browser will display it. Try it!
Why are XBM and XPM the worst graphics file formats for the web? Look at the first byte in the question_bits array: 0x00. That's a single byte in the image. It takes six bytes to represent that byte in the XBM file: one each for the characters "0x00", one for the comma, and one for the space! We're not even counting the extra stuff at the beginning.
So, while GIF has the worst file compression of the formats we've talked about so far (about 5:1), XBM files have 1:6 "anti-compression".
TIFF (for Tagged Image File Format) was invented by Aldus Corporation in 1986. It was created for maximum flexibility in exchanging data between machines and applications. You may see a TIFF file produced by a scanner or fax, and often professional printing houses require your images to be in TIFF format, 32-bit, CMYK. The spec is currently controlled by Adobe, and you can get the spec (currently v6.0) and supplements at Adobe's Web Site.
While TIFF files can be compressed (we're familiar with 7 "groups"), when you find a TIFF file in the wild, it's almost always uncompressed 32-bit data.
Since the headers aren't that big in comparison with the data in most TIFF files, TIFF file compression isn't much worse than 1:1, which is better than XBM and XPM, but worse than just about everything else.
Digital cameras commonly produce three kinds of image files (some produce all three, most produce one or two): JPEG, TIFF, and "raw". Raw files represent the image just as it comes off the imaging chip in the camera, and they often contain more than 8 bits of data for each color channel. Some have 12 bits or 14 bits. There's some controversy over whether any camera really captures 16 reliable bits per channel. We're staying out of that fight.
JPEG files have 8 bits per channel. So when you tell your camera to save JPEG files, it normally lops off the low bits in each channel. At the end of the day, you have to publish the file on the web in an 8-bit-per-color format anyway (JPEG or PNG), so does it make sense to keep the extra bits around? Probably, but we generally tell our camera to save its images as JPEGs.
Since raw files have more bits per channel, and since raw files aren't compressed, they're going to be bigger than uncompressed TIFF files (an "anti-compression" as big as 1:2). Add in the fact that there are more raw file formats than you can shake a stick at, very few of them with published specs, and there's just no way raw files belong on the web.
There's an excellent tutorial at Luminous Landscape on raw files and how you may want to manipulate them in Photoshop or Paint Shop Pro to emulate the camera's built-in processing.
Windows bitmap files are the native file format for programs running on Microsoft Windows. They come in four varieties: 2 bits per pixel (black and white), 4 bits per pixel, 8 bits per pixel, and 24 bits per pixel.
There is compression, but curiously only for 4 bpp and 8 bpp files. The compression is very rudimentary (run length encoding). Compression is commonly much worse than the equivalent GIF or PNG files.
Microsoft has never published the spec for .bmp files, though you can pretty much put a working approximation of the spec together from documents in the Microsoft Developers' Network (MSDN) library. Although Microsoft could, in theory, change the format, it's very unlikely that they'll do so after all these years.
The Windows bitmap file format meets none of the three "goodnesses" we talked about for GIF, JPEG, and PNG. The standard isn't public, the file isn't compressed, and web browsers don't support it. Well, that used to be true. Actually one web browser supported it (want to guess whose?) but in recent years the others have picked up .bmp support just to be compatible.
That doesn't mean .bmp files are suitable for the web. They're still the fourth-worst file format in existence, and even if you're inclined to be forgiving about the unpublished spec, there's still the horrible file size (1:1 "non-compression" in 24 bpp mode).
By the way, the things that make Windows bitmap files lousy for the Web also make them lousy as email attachments, postings to newsgroups and so on. Leave your bitmap files at home. In fact, they don't even belong at home. You can reclaim a pretty good amount of disk space if you go through your graphics files (the ones you've made, not the ones the system may use) every couple of weeks and convert them to PNGs.
PBM (2-bit black and white), PGM (8-bit greyscale), and PPM (RGB
color) are terrific graphics formats produced by the
pbmplus
and
netpbm
packages of utilities. Originated by Jef Poskanzer in 1988, these
formats are intended to be a lingua franca between other
bitmap graphics formats. There are now over 220 utilities developed
more or less chaotically and distributed as source code. Generally
you'll convert a file from a regular format to PPM (etc.) with one
of the utilities, manipulate it with other utilities, and finally
use another utility to convert it back to its original format or
a different format. There's no attempt at compression, and there
are text versions of these formats, a little ike XBM, as well as
binary versions.
The first 3 formats together are sometimes called "PNM" for Portable aNy Map, and a utility that has "pnm" in its name (like Bob's pnmtopix) will usually work on any of the three. Although there is no transparency in the original PNM specs, there is work going on to include transparency. You may have noticed that we haven't said anything about PAM. That's because we haven't heard much about it. Could it be too abstract?
Because they aren't compressed,
files in these formats don't belong on the net. But you
may find that web-based applications that generate or manipulate
graphics use PNM files as intermediate files. If you run into files
in those formats, chances are pretty good that you'll be able to
convert them to almost any format you can think of and manipulate
them in myriad ways as long as you've got a little experience
compiling source code. These
are the ultimate geek file formats, and Kelly isn't surprised at all
that when Bob got our first PC in 1995, the first thing he did was
install Cygwin
and compile a substantial portion of netpbm. Paint
Shop Pro has a warm place in his heart because it supports PNM.
So far every file format we've talked about is a bitmap graphics sometimes called raster graphics) format. Another common type of 2D file format is vector graphics. You deal with vector graphics all the time. Nearly all the fonts you use on your computer are specified in a vector (line plus direction) format. That's why it's so easy to scale fonts so that they look good.
Scalable Vector Graphics is a World-Wide Web Consortium standard for vector graphics. The spec is at The W3C site.
That's the good news. Now for the bad news. Only one web browser supports SVG, and it's one you've probably never heard of: Amaya. Brendan Eich, who you may know as the inventor of JavaScript, is the chief architect for Mozilla, and they'll be building SVG capability into their already excellent standards-based web browsers.
Anyhow, SVG files are made for the web. Some day they'll be on the web, and when they are, all the jaggies at the edges of pictures will be a thing of the past. Unfortunately, that day isn't here yet.