How To Create High-Impact Documents

Introduction

This document describes how to create high-impact documents for use with Netscape Navigator and other browsers. The concentration is on features of Netscape Navigator that allow document authors to significantly improve the user experience for documents containing inlined images. Compatibility issues with other browsers are also covered.

Interlaced GIF Images

A standard feature of the GIF image format is the option to store the image data in the GIF file in an interlaced fashion: instead of storing the image's scan lines in exact sequence, equally spaced nonadjacent sets of lines are stored together, and these sets are stored in sequence. (For more information, see page 318 of O'Reilly and Associates' Encyclopedia Of Graphics File Formats, by James D. Murray and William vanRyper.)

Most programs that support viewing of GIF files display both normal and interlaced GIFs completely properly. Netscape Navigator provides an additional feature: since images in Netscape are normally decoded and displayed incrementally (as data comes in over the network), the fact that interlaced GIFs are decoded and displayed incrementally means that the image appears to "fade in".

In Netscape Navigator beta 0.9 and 0.91, this gives a "venetian blind" effect as the data arrives and is displayed. As of Netscape Navigator beta 0.92 and beyond, we have adopted a suggestion from Paul Haeberli of Silicon Graphics and changed our code to replicate available lines of the image during the first three (of four) decoding stages. In this way, the user sees a complete, albeit not fully "fleshed-out" image after the first of the four passes; subsequent passes progressively enhance the quality of the image until, at the end of the fourth pass, the entire image is in place at full resolution.

If you find the above three paragraphs confusing, don't worry. Just try this (image borrowed from NYWeb):

If you are using Netscape Navigator, the first image should have been downloaded and displayed from top to bottom, and the second image should have faded in using either the "venetian blind" effect or the "progressive enhancement" effect, depending on which beta version of Netscape you're using.

If you are not using Netscape Navigator, both images should have appeared just fine anyway.

So, assuming you find the interlacing to be a positive effect under Netscape Navigator, you can convert any GIF image on your server to be interlaced without at all affecting how other browsers view the image. Just use one of these utilities:

JPEG Images

Netscape Navigator fulfills a long-standing request for inlined JPEG images. All you have to do is specify a JPEG-format image as the SRC value for an IMG tag, and Netscape Navigator will decode and display the image just as it would a GIF image.

The big advantage of JPEG images is that the compression ratios can be much higher for most images (particularly "real life" images). JPEG is also a "lossy" compression method, meaning that you don't generally get the exact same image data upon decoding that you had when you encoded the image. During the encoding process, you can generally specify the "quality" of the encoding. Specifying a low quality value can give you an even higher compression ratio.

While Netscape Navigator supports JPEG images across platforms, many existing browsers do not support inlined JPEGs. For your documents to work with those browsers as well as Netscape, your server will have to be smart enough to send GIF images to non-Netscape Navigator browsers and JPEG images only to the Netscape Navigator browsers (and other browsers that support JPEG images -- we expect many browsers will support JPEG as a standard image format in the near future). We will be providing information on how to do this soon.

(Note that HTTP's "format negotiation" support, via the request's "Accept" values, unfortunately generally does not give the server enough information to decide whether to send GIF or JPEG images to the client, since many browsers support sending JPEG images to external viewing applications and therefore tell the servers they support the JPEG format when they do not in fact do so internally. This is a sad deficiency of the current protocol and we expect it to be rectified in the future.)

See a comparison of a GIF image and several JPEG versions of the same image.

Specifying Image Height/Width In The Document

As Netscape Navigator is laying out a new document, it must pause at each inlined image and go over the network to discover the height and width of the image before it can continue laying out the document (because a properly-sized bounding box must be put in place so the document is laid out properly once the image is loaded). Over a network link with any significant latency, this can cause end-user performance problems relative to how quickly the document could be laid out if the browser knew the image's height and width to start with.

For this reason, Netscape Navigator allows you to specify an image's height and width as attributes of the IMG tag. The height and width are normally specified in pixels. For example, if you are inlining an image that is 413 pixels wide and 356 pixels high, the IMG tag would look like this:

    <IMG SRC="foo.gif" WIDTH=413 HEIGHT=356>
Browsers that do not have support for the WIDTH and HEIGHT attributes to the IMG tag will simply ignore them and lay out the document normally.

Netscape Navigator, on the other hand, will use the height and width information to pop in place a properly-sized bounding box upon encountering the IMG tag and will continue laying out the document text, with no performance delay to go discover the width and height of the image over the network. (See the next section for details on what happens if the width and/or height given in the IMG tag are different than the actual width and/or height of the image.)

Most general-purpose image utility programs will give you the exact size of an image in pixels.

Image Auto-Scaling

If you specify WIDTH and/or HEIGHT values in an IMG tag that differ from the actual width and/or height of the image, Netscape Navigator will use the width and height values specified in the IMG tag and scale the actual image to fit.

For example, if you have an image that is actually 123 pixels wide and 78 pixels high, but you create a document that inlines the image as follows:

    <IMG SRC="b.gif" WIDTH=492 HEIGHT=312>
...the image will be scaled to fit the dimensions 492 by 312.

This means you can purposely cause any image (GIF or JPEG) to be scaled to a larger size (or, for reasons I can't imagine, a smaller size) on the fly, by Netscape Navigator. See an example of scaling in action.

As before, browsers that do not do auto-scaling will cleanly ignore any WIDTH and HEIGHT attributes you add to your IMG tags and will display the inlined image at the normal, unscaled size.

Percentage Auto-Scaling

The explanation of this feature is entirely in a separate document.

The Low/High Resolution Flip Trick

We have added another extension, called LOWSRC, to IMG, as follows:

    <IMG SRC="highres.gif" LOWSRC="lowres.jpg">
Browsers that do not recognize the LOWSRC attribute cleanly ignore it and simply load the image called "highres.gif".

Netscape Navigator, on the other hand, will load the image called "lowres.jpg" on its first layout pass through the document. Then, when the document and all of its images are fully loaded, Netscape Navigator will do a second pass through and load the image called "highres.gif" in place. This means that you can have a very low-resolution version of an image loaded initially; if the user stays on the page after the initial layout phase, a higher-resolution (and presumably bigger) version of the same image can "fade in" and replace it.

You can freely mix and match GIF (both normal and interlaced) and JPEG images using this method. You can also specify width and/or height values in the IMG tag, and both the high-res and low-res versions of the image will be appropriately scaled to match.

Here are some examples:

If the images are of different sizes and a fixed height and width are not specified in the IMG tag, the second image (the image specified by the SRC attribute) will be scaled to the dimensions of the first (LOWSRC) image. Reason: by the time Netscape Navigator knows the dimensions of the second image, the first image has already been displayed in the document at its dimensions.

Real-World Examples

Here are examples of many of the techniques covered above, as seen in the real world. Suggestions for additions to this list should be sent to marca@mcom.com.

Other Random Notes

Here are some other random pointers to useful information.