runway index

To get back to the top, click on the orange bar on the left of the text.

The Virtual World

Screen images :: Hard Copy :: 8-bit Color :: Speed :: Loading time :: Image types :: Gifs :: JPEGs :: PNG :: General techniques :: Html code :: Links :: Backgrounds :: Transparencies :: Animations :: Resources

Chapter Index

Introduction
History
Getting Connected
Browsers
Copyright
Search Engines
HTML
Linking documents
Newsgroups
Images
Tables
Frames
Graphic crunching
Page Design
Publishing
Javascript
Free Stuff
Styles
DHTML
On-line Shopping
Internationalism
Advertising
Forums and Chat

 

Images

The coding to get images into your page is simple. Getting those images right in the first place is not so simple.

Let's start by looking at how computers display images, and then how web browsers display them. We will then look at the steps you should go through to make your image web friendly. We will then look at the code for getting it into a web page.

We need to think about images in several different ways. What is on screen; what gets printed onto paper; the color spectrum; the bits you don't want to print; the time it takes to display a picture on-screen, and therefore you need to know the speed of the web; and finally, you need to have a rough idea of the impatience level of the average surfer.

Your screen image

A computer displays images on a monitor as a series of dots. These dots are called pixels, which is short for picture elements. Various monitors display pixels at slightly different resolutions, but we will stick to the publishing standard here, which is 72 dots per inch (dpi). This means that there are 72 x 72 pixels in every square inch of the monitor. The larger the monitor, the more pixels there are.

Each pixel is driven by a switch inside the computer's cpu. If the switch is on, then the pixel displays (white), if it is off, it does not display (black). So we have a simple mechanism for displaying black and white images.

A typical small monitor would measure fourteen inches. This does not mean that it measures 14 inches across the top, but rather that it is fourteen inches along the diagonal. It usually refers to the total length diagonally from edge to edge of the tube. Since part of the tube is buried behind the casing, and the screen contains a black band running round the edge, a 14 inch screen probably actually displays slightly less than 13 inches. You could regard the guide measurements as a ripoff.

A typical 14 inch screen would cover approximately 70 square inches. In other words it should contain approximately 72 x 72 x 70 pixels. This means a black and white picture that size would require that many switches (362,880) to accurately represent it onscreen.

The minute you add colour you need more switches. And of course all these switches are driven by the software that has created the image, and therefore translates directly into file size.

The minute you add different shades of grey (greyscale) you also need more switches. If you use 8 switches to control each pixel you can generate 256 colours or shades of grey. If you decide to go the whole hog and generate a picture the size of your small screen in 24 bit colour, you will be attempting to present an image suitable for printing in a glossy magazine. You now have a very big and complex file. Make it bigger to fit on a 21 inch monitor and you will probably find you have quadrupled the size of the file.

The point I am trying to make here is, quite simply, that images get big very quickly.


Hard Copy

When you are creating a picture to print on paper you need to consider the print resolution. You maybe have a laser printer which prints copy at 600 dpi. That glossy magasine will need pictures printed at 2400 dpi. It is not uncommon to scan pictures at 1200 dpi. Once again, the maths is disarmingly simple. A 6 x 4 photograph scanned at 1200 dpi will produce a file 6 x 4 x 1200 x 1200, which gives us a very large file (34,560,000) or 34.56Mb.

We have now looked at two color models, 8-bit and 24-bit. 8-bit colour has a color palette of 256 colors. 24-bit has over 16 million. The only thing we are interested in is what palette is any use for the web.

In theory the web uses 256 colors. But in practise that has been cut down by Netscape to 216, There are several sites where you can download what is called the Netscape Color Cube, and all currently shipping professional page creation tools use this palette. The latest operating systems also have a Netscape color palette built in.

This means that any picture you create for the web should not contain more than 216 colors, and you need to know which ones they are if you are interested in any kind of color integrity in your pictures, otherwise you may find them displaying not quite how you intended.

Web Speed

What is the average speed of the web? Let's have a look at some of the limiting factors.

The speed of the web relates to how fast information goes from your machine to the site you want to view, and how fast that information comes back to your desktop. The factors that limit that speed are as follows:

  • The speed your computer can process information from your modem
  • The speed of your modem
  • The speed of the telephone link from the exchange to your home
  • The availability of access through your ISP
  • Traffic travelling along the backbone of the Internet
  • The amount of traffic trying to connect to the site you wish to visit

Let's look at all of these and try to come up with some kind of average speed.

If you have a slow processor, not a very efficient cache system, and an outmoded bus architecture, your computer is not going to be working at top speed. There will be bottlenecks in your own system. For speed you need the latest machine on the market.

You need a reasonably high speed modem. You should be buying the fastest on the market. That means a 56k machine. These modems don't deliver 56k, but they do quite often deliver something in the region of 40k, in one direction.

The link between your home/office and the telephone exchange is probably not very good. It is no doubt analog, and noisy. Those two factors will limit the speed of data transfer. 33.6k is very close to the theoretical speed limit.

This can be overcome by using an ISDN line, which is digital, and therefore capable of higher speeds. You could connect via satellite, or through a cable company. Both methods produce faster throughput rates. But most people don't at present connect this way.

How many users does your ISP have? How much gear does it have? How big is its link to the rest of the Internet? It needs a wide access line out to the net to have any chance of connecting to anything at what might be called speed. You need to know the size of their cable connection.

How much traffic is travelling across the transatlantic link. If you, and ten thousand other eager surfers, are all tunnelling down the pipe from the UK to some steamy site in the US you are going to have to cope with the equivalent of rush-hour-traffic. You will get bogged down, and things will slow to the long drawn out crawl.

And finally, how many other guys are trying to log onto that computer that is carrying those amazing pictures you want to see? The more people trying to log on to the computer you want to log onto, the slower everything will get.

Those are all generalisations. Can we put some figures on all of this?

When accessing the web during the middle of the day (and the evening) from my University connection I have on occasions suffered transfer speeds of as low as 18 bytes per second. That is so slow as to be totally unusable. On occasions like that you have to log off.

On the other hand, at 8.30.a.m. I have connected to a site at speeds of around 70k per second. Now that is really fast. To give you some idea of the difference in downloading times; I have wanted to download an 8Mb file and was quoted one evening a time estimate of two and a half hours. The following morning I downloaded it in three minutes.

On the other hand, my home connection (at 28.8k) typically runs between 1k and 3k per second. I assume most people have approximately the same time-scale.

 

The Patience quotient

The final factor to look at is the average time it takes for people to get fed up. According to a survey I saw a little while ago it seems that IBM asked a few people about their surfing habits. One of the factors measured was the time it took before people got fed up with waiting for something to happen on-screen.

I'm a very impatient person and I get fed up after a small period. I begin to wonder if the machine has crashed, if the connection is duff, if a bomb has hit the system in California, and I start hitting buttons and keys, any keys, Cancel, Stop, another URL.

That usually happens after six or seven seconds. I was therefore a little surprised to find that I am, by the average net standards, a very patient man. Your average person apparently gets fed up after only three seconds.

This has been a long excursion, but we now have some handles to get a grip on size.

Let me throw in one more item which doesn't easily fit in any other category. There is an old saying on the net that if you hold your breath while waiting for a page to download, and you are dead before it happens, then that page is too large.

We know that a good estimate for an average user is a download speed of 2k per second, but we can't guarantee that speed, often it is half that, and maybe less.

We know that people get fed up if nothing happens for three or four seconds. We know that even the most basic image is vast. We therefore also know that if we want to put images on our page we have a major problem on our hands.

We also know that because of the above problems many people turn off images, so they don't display at all. We may deplore that but we have to accept it and plan accordingly.

This means we have to apply a few very simple rules to the use of images.

  1. Any image at the top of a page must be less than 6k in size.
  2. Any image that appears anywhere else on the first six inches (the average screen display) of your page should be less than 12k.
  3. Any image appearing anywhere else on your page should be less than 20k unless there is a very very good reason for it to be larger.

There are obviously bound to be exceptions to these figures. For instance, if you visit the NASA site to look at pictures from various space-craft you probably expect to see a nice picture and are therefore resigned to waiting a while for it to appear.

If you know a map is going to be downloaded you probably expect that to take some time. You may not be happy about it, but you are prepared for the wait.

You will, however, expect the page creator to have organised things so that the map downloads while you are looking at items which have downloaded first. You will also expect to be told how big certain very big pictures are.

The secret is to mix your images with other things which download quickly, and put the big pictures at the end of your page.

All that is fine and dandy, but if you have pictures on your hard disk taking up 34Mb how the hell do you get them compressed to 10k?

You will also want to put in animated Gifs, some background color, or maybe a picture to act as a kind of watermark to your page. This means large size, lots of screen real estate. Who is going to pay for it? Your viewers certainly don't want to pay in download time.

 

Image types

Let's look at three different types of image, and how we would go about putting them on our page. Then we will look at the code needed to place them where we want them.

A simple image can be any one of three types. You can't bung a BMP file onto the web, or a TIFF, it has to be either a GIF, a JPEG or a PNG.

Gifs are used for images that contain large areas of simple colours. When you create a Gif you are chopping out certain areas of the palette. You therefore end up with a style that is similar to a posterized picture. That is where the colours display in steps rather than in a gradual shading. So if you can step your colour, then you use the Gif format.

If, on the other hand, you have a photograph-like picture with gradual shading of colour, you would use the JPEG format, which compresses what you have but doesn't chop out any particular colour.

PNGs are not really with us yet. They are a new format which will probably gain ground over the coming months. They are smaller, and more efficient, but as yet, they are not much used, so we will ignore them for the time being.

Let us assume we have a simple image which has straight-forward blocks of colour suitable for turning into a Gif. How are we going to do this?

You will probably start off by scanning a picture. This will produce a bitmap image. You will then need to open that picture in an image manipulation program, such as Photoshop. The poor relation of Photoshop is PaintShop Pro. Either of these programs will let you index the colour, change the resolution, and change the size of your picture. You will probably need to do all three.

First, size. Your web page is not going to be more than about 700 pixels wide, and your image is unlikely to take up the whole width of the page so you can reckon to have your image no more than 400 pixels wide if it is meant to be a big picture, or perhaps 100 pixels if it is small.

Remember there are approximately 72 pixels to the inch.

If you intend changing the size of your picture, make sure you maintain the proportions; that is, change the width by the same proportion that you change the height. Your graphics program will allow you to do this. Generally speaking, if you drag the handles of a selected picture to change its size, hold down the Shift key while doing so. This should constrain the alterations to keep the sides in proportion.

When setting up the size of your picture do not set it larger than you will need on your page. The file size that you import will be the size of the original picture, not the size that you decide to make it on the page. If you only want a small picture on the page, make it small in the first place to keep the file size down. Remember that a file that is three inches square is almost half the size of one that is four inches square. That is a large reduction to make to your file size.

At this point let me remind you that your image is not part of your page. You do not embed an image in your page, you merely place a link on the page which sends for the separate image file. That image is then displayed in a placeholder on your page. You decide how big that placeholder is.

If you have a placeholder that is larger than your original picture the picture will degrade. This is because your picture contains a finite number of pixels. Make those pixels fill a larger space and they are set further apart, and your picture begins to look tacky.

Make the placeholder smaller than your picture and you are importing a file that is larger than you need. You should have made the picture file smaller. It will then load faster.

You can also cut down the size of your file by making sure you are not saving it at too high a resolution. You may have scanned your picture at a resolution of 300dpi to get good definition. Do remember that monitors generally only display images at a resolution of 72dpi. Any extra resolution is wasted. Cut down your resolution to 72. From 300 to 72 will mean a 75% reduction in file size.

Next you need to cut out any excess colour information. Generally you will be handling colour in eight-bit mode. What this means in simple English is that your monitor will be displaying 256 different shades of colour. If your image only has yellow and blue in it, and only a couple of shades of each colour, then you certainly don't need information on all the rest, so you can throw it away. This is called indexing the colour.

In Photoshop you have a choice to set the index to any mode from 8-bit down to 2-bit. Set it at the lowest and see if the image still looks good. If it doesn't, try increasing the bits till you get to a stage where the picture quality is acceptable. Often you will find you can get away with a small bit depth. 2-bit gives you 4 colours. 4-bit gives you 8 colours, and so on. You have now probably chopped off a further two-thirds from your file size.

You can possibly go one stage further. Not every picture is square. Maybe you do want the whole of the block to display on your page, maybe you don't. If you don't, you can throw away the bits you don't want.

On many of my pages I have images of aeroplanes. I only wish to display the planes, not the surrounds, so I simply throw away the background.

You can either do this in your graphics manipulation program, or get a program dedicated to just creating transparencies. However, the most up-to-date versions of Photoshop, and PaintShop Pro will handle transparency. Simply select the colour of the background and choose to make it transparent. If you have a mottled background, you can still select it all. First select an area using the maquis tool, and then choosing (in Photoshop) Select Similar from the menu. Then apply a single colour to this selection, then make that colour transparent.

A separate section shows how to do this in Photoshop using a step-by-step approach.

You now have in all probability half the pixels in the picture with no colour information at all. You've just slashed another 50% off the file size.

The other day in a demonstration which was done hurriedly I chose an image at random from the computer in front of me which I had never used before. That image was 105k in size. In web terms that is huge. I went through the routines outlined above and ended up with a file that was only slightly flakey, but was only 4k in size. I should have treated the colour balance a little more carefully. I would then have ended up with a good quality file instead of a slightly tacky one. However, the drop from 105k to 4k is one hell of a reduction.

I have scanned a full page image at 300dpi which produced a file approaching 20Mb. By judicious cropping and color reduction, and the use of all the techniques mentioned above I reduced that file to 37k. It can be done. I would have liked to have got it smaller, but that was as far as I could reduce it.

You can also get your files smaller using the JPEG standard. This applies a reduction algorhythm to the pixels and discards information. In this instance you are throwing away information that you would normally want. You are just trying to do without it. In the previous example we were throwing away information we didn't actually need. However, the JPEG standard is far better at dealing with continuous tone pictures where there are gradations of colour. The program does the throwing away, you just press the relevant button. In PhotoShop you Save a Copy of your document and choose JPEG from the File Type drop down menu.

PNG is set to produce even smaller files, and I will discuss the format when it becomes more widespread.

So what are we going to use these files for, and how do we get them onto our page, and what is the maximum size that is acceptable?

We can use images in several ways on our page. We can import a picture to emphasize our text, or as a company logo, or as a button. We can use a picture as a background image, and we can create an inimation.

Let us look at a simple graphic within the context of some text.

The most obvious is a company logo, or a heading. In company logos you generally find unusual display fonts being used. Within the next twelve months enough people will probably be using version 4.x browsers or better to allow us to use the FONT tags to set our pages in fancy type faces. On the other hand there will probably be trouble reading them if people don't have the fonts on their disk, so their system will substitute another font instead.

If you want to guarantee the reader will see the font you specify, the best way of doing that is to create the text in a graphics program, and then import it as an image into your page. I have examples of that on my site. A particular example is the following

You can even be frustrated here because many people turn off the images when they browse to speed up download. That means you could be worse off with no text showing at all. There is a way round this.

The HTML code for getting your image onto the page is simple:

<IMG SRC="imagename.gif"> where "imagename.gif" is the actual name of your graphics file.

You can add size parameters to this tag. You can also add an ALT tag. This allows you to specify text to display if some blighter has turned off his graphics in the browser window.

<IMG SRC="education.gif" ALT="Education">

This bit of code tells the browser to go and get my picture called "education.gif". If the browser is set not to display graphics the word "Education" will display instead. Not an ideal situation, but an acceptable compromise, given the nature of the net, and the people who use it.

Links

You can use an image as a linking item. You merely need to put together two pieces of code, the code to define the path to the image and the code to define the link path. Below is an example of some code to display an image and set it up as a link to another page. I have also set the border of the image to zero:

<A HREF="../index.html">
<IMG SRC="../pics/HawkerFury.gif"
WIDTH=167 HEIGHT=73 BORDER=0></A>

The image source is straddled by the link reference.

Backgrounds

You can specify a background color for your page. You do this in the HTML coding. It is the first thing you do in the body of your page:

<BODY BGCOLOR="#FFFFFF">

The colour is specified in hexadecimal format as above. Don't try to learn all the permutations. There are over 200 of them. So this is not an image, although it can be.

If you want to get a background showing one colour sliding into another you can create it in a graphics package, and then save it as a JPEG which will maintain the smooth gradation of colours. It need not be large either.

If you create such a picture, make sure it is wide enough to run from the first colour right through to the next. Then adjust the image size so that it is only 1 pixel deep, and save it. As it is only 1 pixel deep it will be a very small file.

When someone calls up your page and it appears in the browser window, the background image file will be called. It will display, find it needs to display again to fill up the space available, and will keep on being called until all the background is filled with repeats of the original image.

If you want to put in a personalised watermark as a background, think it through carefully, and produce an image that will repeat across the page and still look organised, like the tiles on your bathroom wall. This process is called, unsurprisingly, tiling. You create one image, that image keeps repeating across the background of the whole of your page.

Do not create what you think is a page-sized background graphic. Remember that your potential viewers are all using different sized screens, and you can't cater for them all. You have to produce your backgrounds as I have described.

You can download readymade backgrounds. In fact, below is a list of further sites:


Transparencies

You can make a transparency in PaintShopPro very easily. You can do the same in Photoshop, but go to the Photoshop chapter to see how it is done.

Create your image in the normal way, and make sure your background (that is to be transparent) is a single colour.

Reduce the colours to 216 colours or less using the Decrease Color Depth dialog box. Select an Optimized Palette, and Error Diffusion as the reduction method. Also select Include Windows colours and Reduce colour bleeding, and click on OK.

Select the Dropper Tool and pass it over the colour you want to make transparent. Note the index number which is indicated by the "I" in the Colour palette box under the RGB values.

Select File - Save As. Set the image type to Gif - Compuserve and set the subtype to Version 89a - Noninterlaced. Click on the Options button in the Save As dialog box to set the transparency. Select "Set the transparency value to palette entry" and type the index number of the colour you want to make transparent. Click OK, and then OK again.

I mentioned the term "noninterlaced" in the previous paragraph. An interlaced picture is one that is built up on the page gradually by rendering alternate lines, and then rendering the rest of the lines. If your picture is huge you should interlace it. If it is small (as it should be) you don't need to interlace it.

You should create a transparent single pixel gif to use in your page design. Because it is difficult to get browsers to place items exactly where you want them, unless you use the new coordinate tags, and early browsers don't support their use, so many users would not see your pages as you coded them even if you did use these tags. All browsers see transparent images tho, even if they are turned off.

The theory is simple. Create a picture with one color in it. Index the color, then save the file as a GIF. Make the color transparent, then cut the image right down so that it only contains one pixel. Call this image something obvious. I have called mine "trans.gif". I use it a lot. If I want to have my text start a couple of inches across the page I place trans.gif in front, and set it to be 140 pixels long. It pushes my text neatly out across the page, and you can't see the image because it is transparent.

You can do the same to set text both on the left and on the right of the page. Drop the transparent gif between, make it the correct width, and it will act as a column separator.

You can do exactly the same in tables, to pad out cells.

Animations

You can also set images together to form an animation. If you are using a Mac you need Gif Builder, if you have a PC you will need Gif Construction Set. The files created this way are not large. Do make sure that each of the images you are going to sequence is the same size, so they fit within the same border.

You can also create animations using dedicated programs with more sophisticated properties, such as Flash and ShockWave.

 


Compression

The Gif compression standard works by scanning each horizontal line of the image in turn and compressing it. This means that if you have an image which fades from one colour to another (leaving aside the fact that you would probably save it as a jpeg) the gif standard will compress it much more if the fade runs from top to bottom rather than from side to side.

Copyright

It's difficult to hang on to your property on the net, but there are two methods of "watermarking" your pictures. The first is Steganography, which hides copyright messages and contact details within the picture. More details of how it works at the steganography site.

Digital watermarking is a more recent develpment. It also works by hiding infomration in the image data. This information is typically a short ID code and is hidden several times within the same picture. The most widely used system is DigiMarc. When you register at the DigiMarc site you get a User ID and a free utility which reads these IDs.


Resources

A small free color program for your PC, which also generates the HTML code. It's called Color Conceiver.

Upload your gifs to Gif Wizard's server and it will compress them for you. It will even scan your site and tell you if any images could be better compressed. And Ulead (another online compression tool) is advertised as perhaps the best graphics optimisation tool on the web.

Education Home Page

Runway Index

Back to the Top

© John Clare. runway 1999