Optimizing Web Graphics


The process of preparing graphics for display on the Web is called optimization. This process entails choosing how artwork is exported from Illustrator, what file formats are being used, and what settings are being used for each file type. Illustrator offers several features, such as Web slicing and Save for Web, which helps you create the best-looking Web graphics.

Creating Web Slices

One way to optimize Web graphics is to use a technique called Web slicing. In simple terms, Web slicing is the process of cutting a large image into several smaller images, which is desirable for various reasons.

First of all, there's user perception. If you try to load a Web page that has a single large image on it, you sit there impatiently waiting for it to download and appear on the page. But when an image is sliced into smaller parts, each smaller image loads faster, and as a result, it feels like the image itself is loading faster.

On that same note, you can use different file formats for each image slice, which can save some valuable file size space, resulting in a faster-loading graphic overall. As you'll see when we discuss the Save for Web feature, these settings directly impact the final file size (read: download time) of your total image.

Slicing is also helpful if parts of a graphic need to be updated often. Instead of always creating larger images, you can update just a part of the image. Swapping out a slice or two can be more efficient than having to work with one large, bulky file all the time.

Finally, because each slice is its own image, you can assign a link (a URL) to it, effectively making it a button. When someone clicks a sliced part of an image, they are linked to another Web page. Of course, you can specify other functionality for such a button as well.

Any Way You Slice It...

Illustrator offers two ways to create Web slices. The more traditional way is to draw them yourself, but Illustrator can also create slices from objects automatically using a feature called object-based slicing. Let's explore both methods.

Once your artwork is created, you can choose the Slice tool from the Toolbox and click and drag in your document window. When you do, Illustrator draws rectangular regionsslicesand each appears with a number that identifies it (Figure 10.8). As you create slices, other dimmed slices might appear automatically in the document. These are called auto slices. Slices that you create are called user slices. Because the overall image has to be rectangular (for an explanation, see the sidebar "Web Slices = HTML Tables"), and all of the slices must be rectangles as well, Illustrator creates slices as necessary (Figure 10.9). As you continue to create slices, Illustrator updates the auto slices accordingly.

Figure 10.8. Create slices where it makes sense to do so to allow for interactivity or future editing.


Figure 10.9. As you draw slices with the Slice tool, Illustrator creates other slices to fill out the rest of the document.


Web Slices = HTML Tables

So what exactly happens when you create a slice? Illustrator splits a single graphic into multiple images. An HTML table is created, with each cell of the table containing one of these slices, or pieces of the image. In this way, when you display the Web page in a browser, all the sliced-up images appear together, almost like a puzzle. This is an important concept to keep in mind because you can create only rectangular slices.


When you draw a slice with the Slice tool, Illustrator is really drawing a rectangle with no fill and no stroke and making it a slice (Figure 10.10). When you want to edit the slice, you can use the Slice Select tool to change the boundaries of the slice.

Figure 10.10. Slices that you create with the Slice tool appear listed in the Layers palette. They are special rectangles that have their Fill and Stroke attributes set to None.


However, Illustrator also has a different kind of slice. Instead of creating graphics and drawing slices over them, you can apply a slice as an attribute to a selectionsomething that Illustrator calls an object-based slice. To apply this kind of slice, make a selection and then choose Object > Slice > Make. Illustrator uses the bounds of your selected artwork as the area for the object-based slice. Using this method, if you make an edit to your graphic, the slice updates automatically along with it.

If you want to hide all the little squares and numbers that indicate slices on your screen, you can do so by choosing View > Hide Slices.

Editing Slice Attributes

You can specify certain attributes for a slice. Remember that a slice is really a cell in an HTML table. So, for example, a slice can have its own background color or URL link. Once a slice has been defined using either of the two methods described earlier, you can select it with the Slice Select tool. To edit the attributes of a slice, select a slice and choose Object > Slice > Slice Options to specify settings such as URL and ALT text (Figure 10.11). When you specify text as an object-based slice, you can also set the slice to be an HTML slice (rather than an image slice). In that case, Illustrator exports the text as editable HTML instead of as a graphic.

Figure 10.11. The Slice Options dialog gives you the ability to assign specific URLs and additional information for each slice in your document.


When exporting files in the Photoshop file format, you can preserve slices defined in Illustrator. Refer to Chapter 12, Saving and Exporting Files, for more details.



HTML text slices might not format exactly as you see them in Illustrator. Although bold or character attributes are preserved, exact fonts and sizing depend on the browser used. Other text features, such as kerning and baseline shift, are ignored.

Once you have created all of your slices, you can choose individual file formats and additional settings by using the Save for Web feature, which we discuss in detail right about . . . now.

Using the Save for Web Feature

At one time, saving a graphic for use on the Web was a difficult task that involved saving an image, opening it in a Web browser, and then repeating that process again and again. Illustrator's Save for Web featurewhich is also found in Photoshop and GoLiveis actually a component of Adobe ImageReady and allows you to speed up the process of optimizing and saving Web graphics.

Once you're ready to export a final version of your Web graphic, choose File > Save for Web to open the Save for Web dialog. The dialog, which fills up most of your screen, is split into several different sections (Figure 10.12). Along the far left are several tools that you can use within the Save for Web dialog. In the center, a preview pane allows you to view up to four different versions of your art. The upper right side offers a variety of different export formats and their settings and the lower right side offers a trio of palettes that control color, image size, and layer settings. Along the bottom of the dialog are zoom controls, color information, and a Preview in Browser button.

Figure 10.12. The Save for Web dialog is almost an entire application within itself.


Let's take a closer look at each of the individual sections of the Save for Web dialog.

  • Save for Web Toolbox. The Save for Web dialog has its own Toolbox, which is the first indication that this feature is above and beyond just a simple dialog. The Hand tool is used to pan the view of your artwork; it is especially useful when you are viewing your art at higher zoom levels. The Slice Select tool enables you to select a particular slice with which to work. The Zoom tool allows you to change the zoom setting of your artwork, and the Eyedropper tool can be used to sample color from an image that appears in the preview pane. In addition to the icon that indicates the eyedropper color (you can click it to get the Color Picker), there's also a button that toggles slice visibility on and off.

  • Preview Pane. The preview pane is the main feature of the Save for Web dialog. By clicking any of the four tabs, you can choose to view your original art (as it appears on the Illustrator artboard), an optimized version of your art (based on the current file settings chosen), and 2-Up and 4-Up versions of your art. Using the 2-Up and 4-Up tabs, you can easily compare different file settings, or how an optimized file looks compared to its original version. Illustrator displays useful information below each preview, including file size and estimated download times, making it easy to find just the right file type for your image (Figure 10.13).

    Figure 10.13. Besides being able to preview the results of different file and compression settings, you can also view file size and estimated download times.


  • Zoom Control. The zoom control allows you to easily choose from a preset zoom level to view your artwork. Alternatively, you can enter any number in the zoom field.

  • Color Information. As you move your mouse over artwork in the preview pane, the Save for Web dialog provides feedback for colors in real time. This is helpful if you want to confirm color information or if you want to sample a specific color from an image.

  • Preview in Browser. The preview in browser function is a huge timesaver. Although you get a beautiful preview of your artwork in the preview pane of the Save for Web dialog, it can be useful at times to see what your artwork looks like in an actual Web browser. This is especially useful for when you want to preview SWF animations, because those do not preview in the Save for Web dialog. Clicking the icon previews the selected artwork in your computer's default Web browser. Clicking the arrow pops up a list of installed browsers that you can choose from (Figure 10.14), or you can edit the list of browsers to customize it to your needs.

    Figure 10.14. The Preview in Browser feature makes it easy to quickly see what your art will look like when rendered in your favorite Web browser.


The two remaining sections, which feature the group of three palettes and the ability to choose from different file types are covered individually, in the following sections.

Choosing the Right Image File Type

Overall, the main benefit of using the Save for Web feature is the ability to compare the final results of multiple file formats, and choosing the one that fits best for a particular use. To make the right decision, you have to understand the differences between each of these file formats, and what their strengths and weaknesses are. Let's take a closer look.

To get an exact image size when you're exporting via the Save for Web dialog, draw a rectangle around your artwork and choose Object > Crop Area > Make. The Save for Web feature honors Illustrator's crop area setting when you're exporting graphics. Any artwork that appears outside of the crop area is not exported.



Choosing the GIF File Format

A common image file format used on the Web, the GIF format (Graphics Interchange Format) was developed by the people at CompuServe, one of the pioneers of the Internet and the Web, though you hardly hear their name mentioned today (amazing how fast things change). Recognizing the need to send graphics files across modem connections (which in those days, were quite slow), they developed the GIF file format, which can contain a maximum of 256 colors and which uses a lossless method of compression. A GIF tries to save space by looking for large areas of contiguous solid color; this makes the format perfect for logos, backgrounds, text headlines, and the like. However, the 256-color limit and the limited compression for images with a lot of detail make the GIF format a bad choice for photographic content.

The GIF format supports other features, including the ability to control the exact number of colors present in the file and the ability to specify a single color of the file as being transparent.

When you choose the GIF file format in the Save for Web dialog, you have the following settings available:

  • Color Settings. The color table settings enable to you to specify exactly how many colors the GIF will contain. Lower numbers of colors result in smaller file sizes but could also result in lower quality images. Because a GIF can contain a maximum of 256 colors, you can choose from several color-reduction algorithms, including the restrictive option, which chooses only Web-safe colors.

    GIF files can also contain multiple images or frames, creating an animation, although Illustrator doesn't support the creation of animated GIF files.



  • Dithering. The dither settings control what method of dithering is used when the image calls for a color that isn't available in the reduced set of colors, or when the image is displayed on a computer screen that doesn't support enough colors to display the image.

  • Transparency. The transparency setting enables to you to define a single color that will display as transparent in a browser. For example, if you want to place a logo on a colored background, you can specify the background color of the GIF to be transparent; doing so causes the background color in the browser to show through those transparent areas. The edges where color meets the transparent edge are usually white when displayed in a browser, and specifying a matte color that matches the background ensures that the edges of your art blend seamlessly into the background (Figure 10.15).

    Figure 10.15. The image on the left was saved with a Matte setting that matched the background on which the art would eventually appear. The image on the right used the default Matte setting of white.


  • Interlacing. An interlaced image loads gradually in a Web browser. First, in a low resolution, and then in a higher resolution in a second and third pass. This allows the image to appear in the browser immediately so that viewers can get an idea of what the page will look like, and then after a few seconds, the higher quality image appears. Turning interlacing off means the image won't display on a Web page until the entire image has been downloaded.

  • Web Snap. By specifying a value in the Web snap field, you can have Illustrator ensure that a certain percentage of the colors used in the graphic are actually Web-safe colors.

Choosing the JPEG File Format

JPEG (pronounced jay-peg) stands for Joint Photographic Experts Group, and it was created to allow photographers to share images using a standard file format. JPEG files can contain millions of colors and use a lossy compression method. Digital images usually contain more color information than the human eye can see or detect, and by throwing out some of that extra information, JPEG images can achieve amazing file size savings. For example, a 10 MB photograph can easily be compressed into a JPEG that's less than 1 MB.

Because the JPEG format supports millions of colors (as opposed to only 256 in a GIF), it's the perfect format to use for photographs or images with complex colors and gradient fills. However, JPEG files do not support transparency as GIF files do.

When you choose the JPEG file format in the Save for Web dialog, you can choose from the following settings:

  • Compression/Quality. The Quality settings enable you to specify how much information is thrown out of a file when the file is compressed. The settings are actually a bit confusing in the way they are presented in the dialog. You might think that a setting of Maximum would mean the highest compression with a smaller resulting file size, but that's incorrect. To prevent confusion, it's best to think of these settings as quality settings. A setting of Maximum means the best quality of an image, meaning less information is being tossed from the image (Figure 10.16). The result is a better-looking image that is larger in file size. Alternatively, you can specify numerical values in the Quality field. A setting of 100 is the same as choosing the Maximum setting.

    Figure 10.16. Don't be confused by the different settings for JPEG compression. For the best quality, choose Maximum. For the smallest file size, choose Low.


  • Blur. One of the most noticeable side effects of compression in a JPEG file is artifacts or stray pixels that appear in the image. Specifying a blur amount can help cover up those artifacts.

  • Matte. The matte setting enables you to specify a color for the edge of the graphic, thus allowing it to blend smoothly into colored backgrounds.

  • Progressive. The progressive setting allows a JPEG image to load gradually in a browser, similar to the interlacing setting we discussed, which is available for GIF images.

Choosing the PNG File Format

The PNG (pronounced ping) format was developed mainly as an alternative to the GIF format. Shortly after the GIF format became popular on the Web, the Unisys corporation, which developed the actual compression algorithm used in the GIF format, tried to collect royalties on its technology from those who used the GIF format. To get around the legal issues, an open standard called PNG (Portable Network Graphic) was developed. The PNG format utilizes lossless compression and can support millions of colors. Instead of allowing you to specify a single color as being transparent, the PNG format also supports 256 levels of transparency, similar to alpha channels inside Photoshop.

Older Web browsers require a special plug-in to view PNG files, although most newer browsers can display them natively. PNG files also might not be compatible with some PDA devices and cell phones. PNG files come in two varieties, 8 bit and 24 bit. The different optimization settings for PNG-8 are identical to those found for the GIF format, mentioned previously.

Choosing the SWF File Format

SWF (Shockwave Flash) is a popular Web-based file format that supports both vectors and rasters. This Flash file format has become extremely popular because of its capability to contain interactive or animated content. You can use Illustrator to generate a SWF file that you want to upload directly to a Website or to create art for import into Macromedia Flash for further editing.

When you choose the SWF file format in the Save for Web dialog, you can choose from the following settings:

  • File Options. You can create SWF files in one of two ways: AI File to SWF File, which creates a single SWF file that contains all of your Illustrator artwork; and AI Layers to SWF Frames, where each layer is converted into a keyframe, resulting in a single animated SWF file. Additionally, you can choose the Protect File option to prevent others from opening the resulting SWF file. The Text as Outlines options converts all text to outlines (so no font files are necessary) and you can make the file size smaller by choosing the Compressed option. The Curve Quality setting controls the fidelity of curved paths.

    The Macromedia Flash (SWF) export dialog offers additional options for creating SWF files that are not present in the Save for Web dialog. For detailed information about the Flash format and these additional settings, see Chapter 12.



  • Appearance. When using transparency or other special effects in Illustrator, you can choose to Preserve Appearance, which flattens any effects as necessary, or you can choose the Preserve Editability Where Possible option if you plan on opening the file in Macromedia Flash in order to edit it. This way you can make additional tweaks to the artwork if you need to.

  • Animation Settings. If you choose the AI Layers to SWF Frames option, all layers in your Illustrator file become keyframes and play as an animation when the SWF file is viewed in a Web browser. The Frame Rate setting controls the speed at which the animation plays (you can't control the timing of individual frames like you can in a GIF animation), and the Looping option forces the animation to repeat continuously. More information on creating animated SWF files is covered later in this chapter.

Illustrator uses Apple QuickTime to preview SWF files within the Save for Web dialog. If you don't have QuickTime installed, you won't be able to preview SWF files and will have to use the Preview in Browser feature to do so.



Choosing the SVG File Format

SVG (Scalable Vector Graphics) is an XML-based file format that is used primarily on the Web and has recently become more popular in creating content for cell phones and handheld wireless devices.

Most Web browsers require a special plugin to view SVG files, although some of the newer versions of browsers, including Firefox and Apple's Safari are beginning to support SVG files natively. Because SVG files are text-based, they can be edited easily, even after they have been exported and uploaded to a Web server. Because of this ability, SVG files are used in data-driven server-based workflows where customized content is a necessity.

When you choose the SVG file format in the Save for Web dialog, you can choose from the following settings:

  • DTD. The DTD (Document Type Definition) setting is akin to the version of SVG with which your file is compatible. Because SVG is an open standard, additional specifications are revised and approved. If you save an SVG file with a particular DTD, it means that your file will be compatible with any device that supports that DTD. Newer specifications usually support more functionality than the older ones did. SVG Tiny (also referred to as SVG-t) is a subset of SVG used for displaying content on SVG-enabled cell phones. SVG Basic is another subset used for displaying content on PDAs.

    You can find more information on SVG at www.svg.org and www.adobe.com/svg.



  • Fonts. When text is present in your file, you can specify the Adobe CEF type, which results in better-looking text when your file is viewed with the Adobe SVG Viewer, but which may not be supported with other SVG viewers. The SVG creates more compatible text, but this text may not be as readable at smaller font sizes. Alternatively, you can convert all text to outlines, which increases file size.

  • Images. When you save a file in SVG, you have the ability to embed any images within the SVG file (making for larger, but self-sufficient files), or you can choose to create smaller SVG files by using the Link option.

  • CSS Properties. There are a variety of ways to format SVG code, and the CSS Properties settings allows you to determine how object attributes are coded within the file. For the most part, this setting affects the performance of your file when viewed.

  • Decimal Places. Illustrator allows you to specify how precisely vector paths are drawn. You may choose a value from 1 to 7, where higher numbers result in better-looking paths at the expense of file size and performance.

  • Encoding. When you save an SVG file that contains text, you can specify a character encoding, including ISO-8859-1 (suitable for European languages), and 8- or 16-bit Unicode (suitable for more complex languages).

  • Optimize for Adobe SVG Viewer. If people will be using the Adobe SVG Viewer to view your SVG files, you can check this option, which takes advantage of proprietary optimizations that exist in the Adobe SVG Viewer, including faster rendering of SVG Filter Effects.

Choosing the WBMP File Format

The WBMP file format, which stands for Wireless Bitmap, is a format that is optimized for wireless devices that have slow connections and limited display capabilities. These devices are quickly fading because newer phones are being introduced constantly and cell phones are the largest-selling consumer electronic devices worldwide. WBMP files are black-and-white images (color isn't supported) and are optimized via a dithering setting.

Specifying Additional Image Settings

In addition to choosing a file format, Illustrator's Save for Web allows you to control how colors, image sizes, and layers are treated when saving your files. These settings are found within the three palettes that appear at the lower right side of the Save for Web dialog.

Color Table

The Color Table palette displays a complete list of all of the colors that are contained within the selected slice. Colors that appear with little diamond icons are Web-safe colors (Figure 10.17). Using the Eyedropper tool to sample colors, you can click the Maps selected colors to transparent icon beneath the palette to specify a color that will appear as transparent.

Figure 10.17. Illustrator indicates Web-safe colors in a color table with tiny diamond-shaped icons.


Image Size

The Image Size palette gives you feedback on the actual size of the selected slice, and it also allows you to specify new sizes, although it's always better to make changes to image size on the Illustrator artboard, before launching the Save for Web dialog. Of importance are the Anti-Alias button and Clip to Artboard check boxes. By default, Illustrator anti-aliases artwork that is exported from the Save for Web dialog and exports artwork based on the art's bounding box or your crop area setting. To have the Save for Web dialog honor the artboard size, you can check the Clip to Artboard setting.

Layers

If you specified layers in your Illustrator document, you have the option of exporting those layers as CSS Layers by checking the Export as CSS Layers option in the Layers palette found in the Save for Web dialog. CSS, which stands for Cascading Style Sheets, allows you to take advantage of absolute positioning and overlapping objects within a Web page. Although the technical aspects of CSS are outside the scope of this book, it's important to realize that CSS has become a standard, especially when you're generating content that will be displayed on a wide range of devices.

If you choose to export Illustrator layers as CSS layers, you can choose whether each top-level layer in your document should be exported as being visible, or hidden (Figure 10.18). Alternatively, you can specify that certain layers aren't exported at all.

Figure 10.18. CSS Layers that are exported as hidden can be activated via scripts on the server using Dynamic HTML.


For more information on CSS, refer to Stylin' with CSS: A Designer's Guide by Charles Wyke-Smith (New Riders, 2005).



Featured Match-Up: Web Slicing vs. CSS Layers

If you think about it, no matter whether you choose to export Web graphics as a group of slices or as CSS layers, you end up with a single graphic that is broken down into several parts. But there's a big difference between these two approaches. In fact, you can almost categorize Web slicing as yesterday's technology and CSS Layers as the way of the future.

As we mentioned earlier, Web slicing is a process of taking a single image and converting it into an HTML table. Each cell in the table contains a different portion of the image, and when the entire table is rendered within a browser, you can see the entire graphic. Although this method of slicing is widespread, HTML tables were never intended to be used in this way. As a result, when these tables are displayed on handheld devices or different browsers, the results can vary. Sometimes, the images may not appear as intended at all. In addition, a limitation in HTML is that images cannot overlap each other, which makes designing with slices an exercise in careful planning.

In contrast, CSS layers are an open standard built on the premise that Web graphics will be displayed on a variety of different devices. When CSS layers are used, there's a good chance your artwork will appear as intended even on smaller devices. In addition, CSS layers support overlapping graphics, and each layer can be programmed with interactivity, meaning you can have layers animate independently and also appear and disappear based on user-defined parameters. To take full advantage of CSS though, Illustrator alone won't be enough and you'll want to add functionality on your own through the use of applications like GoLive or Dreamweaver.





Real World Adobe Illustrator CS2
Real World Adobe Illustrator CS2
ISBN: 0321337026
EAN: 2147483647
Year: 2003
Pages: 147
Authors: Mordy Golding

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net