27
Images in web pages

Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Embed Size (px)

Citation preview

Page 1: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Images in web pages

Page 2: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Images

• Why do we use images?• They add interest, and keep the user from being

bored• They convey information

– Charts are easier to understand than tables of figures– Photographs give sense of processes or locations

better than words – Logos remind us of corporate identity– Icons convey functional meaning

• Some images are invisible!– Eg “shims” to create space

Page 3: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Images

• We can add images to our HTML pages using an image tag.

• An image tag has several attributes, some of which are mandatory, and some that are optional.

• The image tag <img src=“” /> is an empty tag (similar to the <br /> tag).

• We simply insert an image, and don’t need to tell the browser where the image ends.

Page 4: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

IMG

• <img src="imgs/simple/shim.gif" width="38" height="5" border="0“ alt=“” />

• Src= the source URL of the image, or the path to it

• Width and height attributes tell the browser how much space to allow

Page 5: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Measurements

• Width and height are measured in – Pixels, or– Percentage of page size

• Note that attributes take “quotation marks”

• You can force an image to cover the page background by using “100%”, but – Small images enlarged by instructions to the browser

display as poor quality– Large-enough images to give good quality will be slow

to download over slow connections/modems– The browser uses time and processor power to

manage resizing

Page 6: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

IMG

• <img src=“imgs/simple/shim.gif” width=“38” height=“5” border=“0” alt=“”>

• Sometimes you want a border round an image, but more often you don’t– This example is a “spacer” making white space on the

page, so does not need a border– Borders are measured in pixels– Again, attributes take “quotation marks”

• Be careful that the quotation marks in your HTML are “straight quotes” not the “curly quotes” shown here or in Word

Page 7: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

ALTernative text

• alt=“ ”• Use the ALT tag to provide alternative text for

your image. – Text is displayed by the browser when you mouse

over the image – While loading (and if it doesn’t display at all) it is

represented as a small text box– Empty ALT tag alt=“ ” tells a screenreader to skip

the image – Lack of ALT tag forces a screenreader to tell the user

there’s an image - because there’s no way of knowing how important the image may be.

Page 8: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

ALTernative text

• Good ALT tags tell users more about your images even if they are fully sighted

• Keep ALT tags short and informative – Alt=“road blocked by fallen trees”

Page 9: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Images

• Positioning images on the page can be done with the ALIGN attribute, but– Like many older HTML tags this is deprecated and

the use of style sheets is preferred• <style type="text/css">• <!--• img {• padding: 10px;• float: left;• position: static;• }• -->• </style>

Page 10: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Image controlled using CSS

Page 11: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Image Maps

• Areas of an image can be defined as hot spotshot spots• These enable the browser to hyperlink to other

pages or areas

Page 12: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Image Maps

• Useful for “cheap and cheerful” buttons– make a simple background in Photoshop

• Dreamweaver makes image mapping easy– no “user feedback” other than the hyperlink cursor

“finger” and the jump to new content

• Defining the co-ordinates for it by hand is tedious

Page 13: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Image Map example

These are set up as hot spots

Page 14: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Image Map example

Clicking on the mapped hot spot activates the hyperlink and loads a new page

Page 15: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Image types• Characteristics, advantages and

disadvantages

• Vector images– “Line” drawings, computer graphics

• Bit-mapped or raster images– Photographs, “painted” images

Page 16: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Vector images

• Define areas or lines mathematically• Scalable without loss of definition• File sizes do not increase with image size• Often look artificial, “computer generated”

– which may be what you need

• Small file storage• Best-known web format is Flash (exported

as .swf)• New standard – Scalable Vector Graphics

or .svg – slowly being supported

Page 17: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Vector image examples

Scalable without loss of definition

Clip art file, .wmf format

Clip art file, .cgm format

Page 18: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Bitmapped (raster) images

• Define each pixel in terms of colour, intensity and position

• Not just Windows “Bitmap” format .bmp (though this is a bitmapped format)

• .jpg, .gif or .png used on Web• JPG and PNG can look subtle and lifelike• Potentially LARGE files; 2 x larger image requires

4 x larger storage and up- and down-load time• Compression techniques can make file sizes

smaller, but often at cost of loss of data• Small images don’t scale up well

Page 19: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Bitmapped: GIF

• Graphics Interchange Format

• .gif supports 256 colours

• .gif 89a format supports transparency– Good for buttons and other non-rectangular

shapes

• Supports compression

• Not very realistic for photos with thousands of colours

Page 20: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

GIF images

Small images don’t scale up well

Page 21: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Bitmapped: JPG or JPEG

• Joint Photographic Experts Group

• Supports millions of colours

• Excellent for photographic reproduction– Realistic colour owing to wide range

• Good compression, but algorithm discards data (lossy)– So always keep a high quality version

separately from the web version

Page 22: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

JPG images

Page 23: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Bitmapped: PNG

• Portable Network Graphics• Fireworks’ native format• Supports millions of colours• Supports transparency• Reasonable compression

– But can make larger files than .gif or .jpg

• Increasing browser support– Not all features work correctly in older browsers

Page 24: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

PNG images

Page 25: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Optimising

• Many Internet users still have low bandwidth access

• Images are useful, but have disadvantages

• Most browsers only support GIF, JPG and PNG– only Internet Explorer supports .bmp

Page 26: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Optimising – a practical example

• Define your expected screen minimum (eg 800 x 600px)

• Deduct 40px for scrollbars = 760px• Define any menu width, eg 1/5 of screen width =

~150px• Remainder (610px) is available for content• Decide site policy, eg “Always leave half the

space for text” – 610 / 2 = 305• Therefore images should be less than 305 px

wide

Page 27: Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to

Optimising• Resize your chosen image to 305 px wide (in this case)

– Most photo editor programs link proportions, so the height will adjust

• “Save As” (or “export” or “save for web”) a new copy– using a web friendly format (.jpg, .gif, .png)

• Apply compression – High compression = lower quality = smaller file size = faster

up/download– Low compression = higher quality = larger file size = slower

up/download• Save to image folder with suitable name eg

“house_sml.png”– Try to avoid spaces in filenames as some servers won’t handle

them• KEEP the original safely among source materials for the

site