Lecture 5 Images and Sound
Lecture 5 Images and Sound
Lecture 5 Images and Sound
Lecture Overview
1. Images
Image formats
Handling images in web pages
2. Sounds
Audio formats
Embedding sound into a web page
2
Images
• Non textual digital data including
drawings, photographs and charts.
3
Image File Formats
• Many different graphics file formats
exist.
• Only 3 are best suited for use on the
Web :GIF,JPEG, and PNG.
• Each has its own unique qualities.
• Hence best used for a particular type
of image.
4
(i) GIF Format
•Graphics Interchange Format.
•Supports 256 colors only.
•Suitable for graphics with large blocks
of the same color e.g. drawing.
5
GIF Format
•File saved with .gif file extension
•E.g. file1.gif
•Strength:
•Weakness:
6
(ii). JPEG (Joint Photographic Experts Group)
•Supports millions of color.
•Suitable for photographic images.
•File saved as .jpg
•E.g file1.jpg
•Strength:
•Weakness:
7
(iii) PNG
•Portable Network Graphics.
•PNG combines some of the best qualities
of both GIF and JPEG.
•doesn’t have very broad browser support
at the moment.
•PNG is for the future
8
Inserting Images into a Web Page
• Use the <img src=“” /> element .
• src attribute indicates the source of the
image.
• Example:
<img src=”msulogo.gif” />
• Note: If the image file is in a different
directory, the full file path must be
specified.
9
Setting Image Properties
1. SpecifyingImage’s Dimensions
• add the width and height attributes.
• <img src=”bush.jpg” width=”200”
height=”100” />
• N/B: dimensions are measured in
pixels.
10
Image Properties cont’d
2. Drawing a border round an image
• add the border attribute and set it
equal to the border’s thickness in
pixels:
• <img src=”msulogo.jpg” width=”200”
height=”100” border=”5” />
11
Image Properties cont’d
3. Defining Alternative Text
• Text that is displayed when the
image cannot be located.
• Add the alt attribute:
<img src=”bush.jpg” alt=” George
Bush picture” />
12
Wrap Text and Align Images
13
Wrap Text and Align Images cont’d
14
Wrap Text and Align Images cont’d
15
To control the vertical alignment of an image
relative to text
16
vertical alignment of an image relative to text
cont’d
17
Insert a Background Image
19
Audio and Video
20
MIDI
22
Waveform Audio
23
MPEG
25
Embedding Audio/Video Files
26
• Browsers can’t play audio/video files
without help from other applications
e.g.. Flash player.
• Such programs are called plug-ins or
add-ons.
27
Embedding Audio Files cont’d
3. Controlling Play
• add the autostart = “false” attribute .
• Prevents sound file from automatically
starting to play immediately the page
loads.
• Example:
• <embed src=”backbeat.mid” width=”100”
height=”15” autostart=”false” />
29
4. Adding Background Sounds
<embed src=”backbeat.mid” width=“1”
height=“1” autostart=“true” loop=“-1” />
• Add width=“1” and height =“1” attributes
• This constrains the control panel to a
single pixel that can be hidden anywhere
on the page.
30
• Set autostart =“true” attribute.
• so that the sound begins once the page has
successfully loaded.
• Set loop=“5" attribute.
• Defines the number of times you want the
sound file to play (replay).
31
5. To make the sound play
continuously while the page is viewed
<embed src=”backbeat.mid”
autostart=“true” loop=“-1” />
32