22.06.2015 Views

o_19octlt3v29m1ul81r9513q81i4ra.pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Preparing Graphics for Web Use 143<br />

Different graphics formats have different color depths and compression types, so you<br />

might find that one format is appropriate in one situation but not in another. To convert<br />

a graphic to a different format, open it in any graphics program that saves in multiple<br />

formats, and then save it in a different format.<br />

The following table lists the differences between the major Web-supported graphics<br />

formats.<br />

Name Color Depth Compression Animation Transparency<br />

Graphics Interchange 8-bit (256 colors) Lossless Yes Yes<br />

Format (GIF)<br />

Joint Photographic 24-bit<br />

Lossy No No<br />

Experts Group (JPEG, JPG) (1.6 million colors)<br />

Portable Network<br />

Graphics (PNG)<br />

24-bit or 48-bit Lossless Yes Yes<br />

Preparing Graphics for Web Use<br />

After you decide which graphics format to use for a particular image, your next decision<br />

is how large the graphic should be—that is, how many pixels it should contain. This is<br />

called the image’s resolution, and it is expressed in width and height, always in that order.<br />

For example, an image that is 800 × 600 is 800 pixels wide and 600 pixels tall.<br />

A graphic’s file size—how many bytes the file will take up on disk—has a direct relationship<br />

to its resolution: the more pixels in a graphic, the larger the file. You must strike a<br />

balance between making the resolution of a graphic high enough to display optimally<br />

and low enough to download quickly when users load your page.<br />

There are two ways of controlling the size (in pixels) of a graphic on a Web page:<br />

●●<br />

●●<br />

One method is to use a graphics-editing program to resize it before using it on<br />

the Web page. This method results in the smallest file size possible, which will<br />

allow your page to load more quickly. It is also more work, though, and it prevents<br />

anyone visiting your page from downloading a high-quality copy of your graphic.<br />

(That could be a good or bad thing, depending on the purpose of your page.) The<br />

exercise in “Inserting Graphics,” on page 144 uses a graphic that has already been<br />

resized in this manner.<br />

The other way is to use attributes within the HTML code to specify the height and<br />

width at which the graphic is displayed. The Web browser will scale the graphic<br />

down to the specified size when it displays the page. With this method, the file size

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!