About usContact usSite help
Quick links
Search this site

Web Graphics




Introduction

In designing a Web site that uses graphics there are some related technical considerations to bear in mind:

  • The appearance of the page on the major browsers.
  • The speed that page will be transferred.
  • The total amount of information transferred, in kilobytes, i.e. the "bandwidth" required to transfer that information.

With the enforcement of bandwidth-related limits on Demon's Web services, this final consideration has become very important. Generally, the bandwidth required for a page is primarily determined by its graphical content; the HTML that describes the page layout and textual content will rarely be over a few kilobytes in size, whereas a single graphic file can easily be ten to a hundred times larger.

A good rule of thumb is that you should be aiming to achieve image file sizes of around 20K or less for "inline" graphics that are displayed on your pages - apart from anything else it makes the pages display quickly if these files are small. Graphics files that are not directly displayed should be stored as efficiently as possible, depending on their intended purpose.

Back to top

How do I know how much bandwidth I am using?

This is simple to check. Check in the root directory of your homepage, and you should find a file called bwusage.txt. It details the amount of requests on your page and the amount of bandwidth in Mb that has been taken up.

Back to top

Using the provided images

There are libraries of icons and backgrounds available on Demon's Web servers. Because these images are intended for use on any site on those servers they are cached and do not count towards your bandwidth use. These graphics should not be copied to your own directory. Instead use an absolute reference as described at:
http://www.demon.net/helpdesk/products/homepages/libraries.html (Homepages)
http://www.demon.co.uk/gifs/ (Commercial Web)

Back to top

Choosing the correct size for your images

The first consideration you should have is the appropriate size for the graphics you wish to use on your pages. Although you may think that a large graphic is very impressive, you should bear in mind that an image which is 400x400 pixels in size will generally be SIXTEEN times larger in uncompressed file size than one which is 100x100 pixels. You should "resample" large graphics down to the desired display size and save them in an appropriate format (described below).

If you have a large number of graphics for display it is best to provide them first as "thumbnails" (small images) that may be clicked before the full-size file is downloaded. Do not use WIDTH and HEIGHT settings in your HTML to display large images at small sizes - visitors to your site will have to download the large files anyway to see them at the small size! It is good practice to use accurate WIDTH and HEIGHT settings for inline graphics to speed page display.

If it is likely a whole set of graphics will be downloaded it may be most efficient to put them in an archive (e.g. a "zip" file). If the files are saved in a well compressed format beforehand, the archive can be kept fairly small. Caution: some formats will not compress any further and will actually expand when "zipped". In this case it would be best to archive them with no compression.

Back to top

Graphic file formats

Most Web browsers handle "inline" graphics (i.e. those which are displayed on a page) in GIF or JPEG format. At present no other "raster" or "bitmap" types are as widely compatible or efficient, and any others are best avoided. Some, e.g. Windows BMP, are not compressed at all. Both GIF and JPEG use compression to reduce the size of the files and thus the bandwidth required to transfer them. However they are generally not interchangeable - each is applicable to certain types of image.

GIF format

GIF is the Graphics Interchange Format, originally developed for use on the Compuserve network, but now widespread on the Internet. Its main features are:

  • Every pixel is assigned a colour from a "palette" of up to 256 colours.
  • "Lossless" LZW compression is used (similar to that in "zip" archives) - the displayed output image is identical to the "paletted" one input.

JPEG format

JPEG is the image encoding system of the Joint Photographic Expert Group or more formally is the system used in JFIF (JPEG File Interchange Format). This format is intended for compressing "real-world" scenes. Features include:

  • Images may be greyscale or full colour - there is no "palette".
  • The compression used is "lossy" - the displayed output image is not identical to the original.

Which should I use?

You should use GIF format for:

  • Small images, especially icons.
  • Logos, titles.
  • Images with few colours, e.g. street maps.
  • Flat colour graphics, cartoons etc.
  • Images that you wish to contain some transparent areas.
  • Brief animations (not movies).
  • Very small photographic or continuous-tone images ("thumbnails").
  • Graphics which must be compatible with old or uncommon browsers (these are now rare).

Note that GIF format is not suitable for photographs unless they are small thumbnails.
You should use JPEG format for:

  • Large images with very many colours or smooth, continuous tones.
  • Photographs and full colour illustrations.
  • Images that do not compress well in GIF format.

Note that JPEG format is not suited for line drawings, cartoons, or high contrast, sharply defined images (especially text or icons).

Back to top

How to "optimise" your graphics for small file size


Note that these tips are rules of thumb. Generally the best method for optimising a particular graphic file is to make several versions following these guidelines and choose the smallest file that still looks good on the target browser. See the list at the end of this document for some useful optimisation tools.

GIF palette optimisation

Because this format uses a fixed number of colours, information is discarded to fit the image to the palette, which reduces the file size. This can quite often be done with minimal loss of quality if the palette is chosen well.

For instance, suppose you have an image that is 200x100 pixels in size. A full colour (24-bit per pixel) bitmap image of this size is 60,000 bytes (i.e. 200x100x24/8 bits-per-byte). With a 256-colour (8 bits per pixel) palette this would be reduced to 20,000 bytes. If a suitable 16-colour (4 bits per pixel) palette could be fitted to the image, then the image would use just 10,000 bytes, a sixfold decrease in size! With the LZW compression used in the GIF format this can be reduced even further.

The number of colours visible to the person viewing an image is also a consideration in choosing a palette. For instance someone using Netscape on a standard 256-colour display will generally only be able to see 216 colours from Netscape's default palette. Using any more colours in the graphics on your page may be of no benefit to visitors to your page, and simply increase download times and the amount of bandwidth used.

The process of reducing the number of colours used without significantly degrading image quality is called "palette optimisation". Luckily it is not very complicated to do if you have the right tools - indeed some packages have been developed solely for this purpose.

GIF compression optimisation

If you have an image that appears very grainy, for instance a graphic that has not given good results on scanning, it is unlikely to compress well. This is because the LZW compression scheme uses similarity between pixels to reduce the amount of data needed to describe them; a grainy image has too much randomness to compress well. For this reason blurring an image -very slightly- before saving may produce a smaller GIF file.

If your image should contain areas of flat colour but has some specks of "noise" scattered through it, you can often reduce its final size by "despeckling" it, or retouching the affected areas.

Other GIF options

Interlaced GIFs

This form of encoding makes the GIF image display in progressively higher resolutions as it downloads. However it adds to the size of the file and is best avoided unless the image is unlikely to be downloaded in full (in which case a thumbnail may be better), or the file size penalty is very small.

Animated GIFs

Animation in GIFs is part of the GIF89a standard. The format is displayed correctly in most modern browsers and can be used to good effect. However it is best used sparingly and care must be taken to avoid producing very large files. In general:

  • Don't use too many frames - very few are required for good effects.
  • When appropriate use video formats (AVI, MOV, MPEG, FLC etc) instead of GIF - they are designed for the purpose and generally have better compression.
  • Animate only those areas that are essential - e.g. if you want an eye to wink, there is no point using a second frame of a whole face.
  • Use sensible frame times - don't delay a frame by inserting repeated images - adjust the display time on the first one instead.
  • Use a global fixed palette - localised frame-by-frame palettes are not displayed correctly on all browsers and produce larger file.

JPEG compression

The main tool you can use for keeping the size of your JPEG files down is to alter the compression setting used for encoding the image.

Using high levels of compression in the JPEG format causes blocky "artifacts"of the encoding system to appear around edges in the image. For this reason you may think it is best to choose a minimal compression level (high quality factor). However, even a very slight level of compression (e.g. 5% compression, or 95% quality factor) will drastically reduce the size of a JPEG file with no visible effect on the image quality. Less compression than this will produce a significantly larger file. Very large reductions in file size are achievable if you can tolerate a lower quality (e.g. a large image that is to be used as a "background"). Good results can be seen at around 10%-50% compression settings.

Again, small features and "noise" in an image will stop it compressing so well, so you may want to retouch areas and blur or despeckle an image before saving it as a JPEG. If possible crop areas of superfluous detail entirely - especially ornate borders. Don't be tempted to dither or reduce the colours in an image to be saved as a JPEG; dithering will introduce a lot of "noise" and reduce the compression.

Another tip is not to use "zero compression" or "lossless" JPEGs - they are not standard and it is unlikely that Web browsers will display them.

Progressive JPEGs are not as widely implemented on Web browsers as the equivalent standard ("baseline") format. However they are usually smaller in size, and are supported on most recent browsers (for example MS Internet Explorer 3 and Netscape 3 and above).

Back to top

Other efficient graphic file formats

PNG (Portable Network Graphics)

PNG (pronounced PiNG) is a new format developed to provide a common file type for images with lossless compression, to be used on networks and especially the Web. It generally produces even smaller files than GIF and very much smaller files than "lossless" JPEG or TIFF. The MIME-type associated with this format is supported on Demon's Web servers and can be viewed in the latest version of web browsers. However some image viewers already implement the PNG format, so they could be configured as "Helper Applications" until a plug in becomes available (or browsers can handle it "inline"). Full specifications are detailed in RFC 2083, available at:

ftp://ftp.demon.co.uk/pub/doc/rfc/rfc2083.txt
http://www.boutell.com/boutell/png/

FIF (Fractal Image Format)

Iterated Systems have developed a "lossy" file compression system that uses fractals to reduce the amount of data needed to encode similar areas of an image. It is best suited to full-colour graphics and photographs, producing files which are usually smaller than equivalent JPEGs and allowing repeated enlargement without the pixellation usually apparent with such transformations. The FIF format has a free plug in for common browsers called Fractal Viewer and an associated "MIME-type" is enabled on all Demon Web servers. FIF files can be created using the shareware Fractal Imager. Details are at:
http://www.iterated.co.uk/Products/

Wavelet compression

Infinop Inc. has developed the Lightning Strike Image Compression system - another "lossy" encoding scheme that is intended to allow better compression of full-colour images and photographs than JPEG. Image clarity is improved and the "artifacts" are far less noticeable under high compression. The MIME-type for this format is enabled on Demon's Web servers and a trial version of the compressor, the free decompressor browser plug in and some slide shows are available at:
http://www.infinop.com/

Corel CMX vector format

Corel Corp., makers of the popular CorelDraw software, have produced a plug in to allow Web-based viewing of CMX files (as output from the Corel suite of software). This format is very different from those previously discussed in that it is a VECTOR graphic format. This means that a CMX file contains a description of how to draw the image it contains and not just a "bitmap" description of how to display it. The image can then be displayed at any size - it is interpreted, scaled and displayed by the browser plug in. The format is not suitable for photographs or "real-life" images. It works very well for plans, maps, clipart and business graphics and produces fairly small files.The appropriate MIME-type is enabled on Demon's Web servers and a plug in can be downloaded at:
http://www.corel.com/corelcmx/

Please Note: CMX images can be viewed by Netscape Navigator™ 2.0 for Windows® 95 and Windows NT® only.

Back to top

Useful links

Web graphics optimisation information

The Bandwidth Conservation Society has discussions and examples of optimisation techniques for the common graphic formats, see:
http://www.infohiway.com/faster/index.html

The Dec. 1996 edition of Web Techniques carried the useful article "Optimising Web Graphics - The Great Bandwidth Shortage". This has been expanded and is now online at:
http://webreference.com/dev/graphics/

The JPEG image compression FAQ is available at:
http://www.cis.ohio-state.edu/hypertext/faq/usenet/jpeg-faq/top.html

Notes on Graphic file formats generally are available here:
http://www.dcs.ed.ac.uk/~mxr/gfx/

Web graphics optimisation tools

Many excellent image manipulation and optimisation tools for Windows and Macintosh system are available at:

http://tucows.cableinet.net/grap95.html(Windows95)
http://win3x.tucows.com/softgrap.html(Windows 3.1x)
http://www.allmacintosh.com/imgvwrmac.html(Mac)

Various GIF and JPEG optimisation tools, plug ins and Web enhancements for Windows image editing software are available from ULEAD systems at:
http://www.ulead.com/

More Macintosh image editing and conversion software can be found via ftp at:
ftp://sunsite.doc.ic.ac.uk/packages/info-mac/gst/grf/(please read the 'abstracts').

Linux and Unix users will find pbmplus fufils most of their requirements, or could try ImageMagick for the X Window System. For details see:
http://www.imagemagick.org/

Finally, the online GIF Wizard palette optimisation tool is available at:
http://www.raspberryhill.com/gifwizard.html

Back to top





*