spacer

spacer
activepages

Using Color and Images

Using Color with HTML

Color can be added to your (X)HTML-based pages through the color attribute of the FONT tag or through the bgcolor attribute that can be incorporated into any element that creates a region (e.g., BODY, TABLE, TR, TD, etc.). Valid attribute value are either simple color names or a series of hexidecimal digits following the cross-hatch symbol (also known as a pound symbol): #.

Alternatively, color can be added via your CSS style sheet(s). To add color via a style sheet, add an attribute-value pair to an element using the rgb() function notation demonstrated below — for example, rgb(255,0,255) is a magenta color because the first parameter to the rgb function identifies the intensity of red in the color (255 is the maximum intensity the electron gun in your display can fire at), the second parameter represents the green component (0 is the minimum meaning the electron gun is off completely), and the third parameter represents the blue component. Magenta is defined as a color by maximum red, minimum green, and maximum blue.

In both cases of (X)HTML and CSS, colors are displayed combining RED, GREEN, and BLUE light. We have cells in our retina that are highly sensitive to these three specific wavelengths of light and so this methodology of identifying color matches well with our physiology. It just happens that hexidecimal notation is really great for matching representation to computer architecture - and, it provides a range of color that is just about equal to the color distinction abilities of a typical human being's physiology. Hexidecimal is a base 16 counting methodology — you count from 0 to 9 and then use the letters A through F to represent the digits for 10, 11, 12, 13, 14, and 15. We would all be using hexidecimal more readily if we had eight fingers on both hands. Sometimes computers and humans have different physiologies but we can imagine a computer with eight fingers on each hand to gain a better intuition with how they work for number representation. Humans use imagination well, even if some governments don't showcase that wonderful skill at times. As creative artists, we need to but it doesn't hurt to linger on strict logical representations as well. Go ahead and read all about color representation below.

Color Values

HTML colors are defined using a hexadecimal (hex) notation for the combination of Red, Green, and Blue color values (RGB).

The lowest value that can be given to one of the light sources is 0 (hex 00). The highest value is 255 (hex FF).

Hex values are written as 3 double digit numbers, starting with a # sign.

Color Values

Color Color HEX Color RGB
  #000000 rgb(0,0,0)
  #FF0000 rgb(255,0,0)
  #00FF00 rgb(0,255,0)
  #0000FF rgb(0,0,255)
  #FFFF00 rgb(255,255,0)
  #00FFFF rgb(0,255,255)
  #FF00FF rgb(255,0,255)
  #C0C0C0 rgb(192,192,192)
  #FFFFFF rgb(255,255,255)

Try making your own hexidecimal notation colors here.

16 Million Different Colors

The combination of Red, Green and Blue values from 0 to 255 gives a total of more than 16 million different colors to play with (256 x 256 x 256).

Most modern monitors are capable of displaying at least 16384 different colors.

If you look at the color table below, you will see the result of varying the red light from 0 to 255, while keeping the green and blue light at zero.

To see a full list of color mixes when the red light varies from 0 to 255, click on one of the hex or rgb values below.

Red Light Color HEX Color RGB
  #000000  rgb(0,0,0) 
  #080000  rgb(8,0,0) 
  #100000  rgb(16,0,0) 
  #180000  rgb(24,0,0) 
  #200000  rgb(32,0,0) 
  #280000  rgb(40,0,0) 
  #300000  rgb(48,0,0) 
  #380000  rgb(56,0,0) 
  #400000  rgb(64,0,0) 
  #480000  rgb(72,0,0) 
  #500000  rgb(80,0,0) 
  #580000  rgb(88,0,0) 
  #600000  rgb(96,0,0) 
  #680000  rgb(104,0,0) 
  #700000  rgb(112,0,0) 
  #780000  rgb(120,0,0) 
  #800000  rgb(128,0,0) 
  #880000  rgb(136,0,0) 
  #900000  rgb(144,0,0) 
  #980000  rgb(152,0,0) 
  #A00000  rgb(160,0,0) 
  #A80000  rgb(168,0,0) 
  #B00000  rgb(176,0,0) 
  #B80000  rgb(184,0,0) 
  #C00000  rgb(192,0,0) 
  #C80000  rgb(200,0,0) 
  #D00000  rgb(208,0,0) 
  #D80000  rgb(216,0,0) 
  #E00000  rgb(224,0,0) 
  #E80000  rgb(232,0,0) 
  #F00000  rgb(240,0,0) 
  #F80000  rgb(248,0,0) 
  #FF0000  rgb(255,0,0) 


Shades of Gray

Gray colors are displayed using an equal amount of power to all of the light sources. To make it easier for you to select the right gray color we have compiled a table of gray shades for you:

Gray Shades Color HEX Color RGB
  #000000  rgb(0,0,0) 
  #080808  rgb(8,8,8) 
  #101010  rgb(16,16,16) 
  #181818  rgb(24,24,24) 
  #202020  rgb(32,32,32) 
  #282828  rgb(40,40,40) 
  #303030  rgb(48,48,48) 
  #383838  rgb(56,56,56) 
  #404040  rgb(64,64,64) 
  #484848  rgb(72,72,72) 
  #505050  rgb(80,80,80) 
  #585858  rgb(88,88,88) 
  #606060  rgb(96,96,96) 
  #686868  rgb(104,104,104) 
  #707070  rgb(112,112,112) 
  #787878  rgb(120,120,120) 
  #808080  rgb(128,128,128) 
  #888888  rgb(136,136,136) 
  #909090  rgb(144,144,144) 
  #989898  rgb(152,152,152) 
  #A0A0A0  rgb(160,160,160) 
  #A8A8A8  rgb(168,168,168) 
  #B0B0B0  rgb(176,176,176) 
  #B8B8B8  rgb(184,184,184) 
  #C0C0C0  rgb(192,192,192) 
  #C8C8C8  rgb(200,200,200) 
  #D0D0D0  rgb(208,208,208) 
  #D8D8D8  rgb(216,216,216) 
  #E0E0E0  rgb(224,224,224) 
  #E8E8E8  rgb(232,232,232) 
  #F0F0F0  rgb(240,240,240) 
  #F8F8F8  rgb(248,248,248) 
  #FFFFFF  rgb(255,255,255) 


Cross-Browser Color Names

A collection of nearly 150 color names are supported by all major browsers.

View the cross-browser color names


Web Standard Color Names

The World Wide Web Consortium (W3C) has listed 16 valid color names for HTML and CSS:

aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow.

If you want to use other colors, you should specify their HEX value.


Web Safe Colors?

Some years ago, when computers supported max 256 different colors, a list of 216 "Web Safe Colors" was suggested as a Web standard, reserving 40 fixed system colors.

The 216 cross-browser color palette was created to ensure that all computers would display the colors correctly when running a 256 color palette.

This is not important now, since most computers can display millions of different colors. Anyway here is the list:

000000 000033 000066 000099 0000CC 0000FF
003300 003333 003366 003399 0033CC 0033FF
006600 006633 006666 006699 0066CC 0066FF
009900 009933 009966 009999 0099CC 0099FF
00CC00 00CC33 00CC66 00CC99 00CCCC 00CCFF
00FF00 00FF33 00FF66 00FF99 00FFCC 00FFFF
330000 330033 330066 330099 3300CC 3300FF
333300 333333 333366 333399 3333CC 3333FF
336600 336633 336666 336699 3366CC 3366FF
339900 339933 339966 339999 3399CC 3399FF
33CC00 33CC33 33CC66 33CC99 33CCCC 33CCFF
33FF00 33FF33 33FF66 33FF99 33FFCC 33FFFF
660000 660033 660066 660099 6600CC 6600FF
663300 663333 663366 663399 6633CC 6633FF
666600 666633 666666 666699 6666CC 6666FF
669900 669933 669966 669999 6699CC 6699FF
66CC00 66CC33 66CC66 66CC99 66CCCC 66CCFF
66FF00 66FF33 66FF66 66FF99 66FFCC 66FFFF
990000 990033 990066 990099 9900CC 9900FF
993300 993333 993366 993399 9933CC 9933FF
996600 996633 996666 996699 9966CC 9966FF
999900 999933 999966 999999 9999CC 9999FF
99CC00 99CC33 99CC66 99CC99 99CCCC 99CCFF
99FF00 99FF33 99FF66 99FF99 99FFCC 99FFFF
CC0000 CC0033 CC0066 CC0099 CC00CC CC00FF
CC3300 CC3333 CC3366 CC3399 CC33CC CC33FF
CC6600 CC6633 CC6666 CC6699 CC66CC CC66FF
CC9900 CC9933 CC9966 CC9999 CC99CC CC99FF
CCCC00 CCCC33 CCCC66 CCCC99 CCCCCC CCCCFF
CCFF00 CCFF33 CCFF66 CCFF99 CCFFCC CCFFFF
FF0000 FF0033 FF0066 FF0099 FF00CC FF00FF
FF3300 FF3333 FF3366 FF3399 FF33CC FF33FF
FF6600 FF6633 FF6666 FF6699 FF66CC FF66FF
FF9900 FF9933 FF9966 FF9999 FF99CC FF99FF
FFCC00 FFCC33 FFCC66 FFCC99 FFCCCC FFCCFF
FFFF00 FFFF33 FFFF66 FFFF99 FFFFCC FFFFFF

Understanding image file types

Image file sizes

Image file size — expressed as the number of bytes — increases with the number of pixels composing an image, and the colour depth of the pixels. The greater the number of rows and columns, the greater the image resolution, and the larger the file. Also, each pixel of an image increases in size when its colour depth increases — an 8-bit pixel (1 byte) stores 256 colours, a 24-bit pixel (3 bytes) stores 16 million colors, the latter known as truecolor.

Image compression uses algorithms to decrease the size of a file. High resolution cameras produce large image files, ranging from hundreds of kilobytes to megabytes, per the camera's resolution and the image-storage format capacity. High resolution digital cameras record 8 megapixel (1MP = 1,000,000 pixels / 1 million) images, or more, in truecolor. For example, an image recorded by an 8 MP camera; since each pixel uses 3 bytes to record truecolor, the uncompressed image would occupy 24,000,000 bytes of memory — a great amount of digital storage for one image, given that cameras must record and store many images to be practical. Faced with large file sizes, both within the camera and a storage disc, image file formats were developed to store such large images. An overview of the major graphic file formats follows below.

Image file compression

There are two types of image file compression algorithms: lossless and lossy.

Lossless compression algorithms reduce file size without losing image quality, though they are not compressed into as small a file as a lossy compression file. When image quality is valued above file size, lossless algorithms are typically chosen.

Lossy compression algorithms take advantage of the inherent limitations of the human eye and discard invisible information. Most lossy compression algorithms allow for variable quality levels (compression) and as these levels are increased, file size is reduced. At the highest compression levels, image deterioration becomes noticeable as "compression artifacting".

The images below demonstrate the noticeable artifacting of lossy compression algorithms; select the thumbnail image to view the full size version.[1]

Lossless Image Compression
Lossy Image Compression

Major graphic file formats

Including proprietary types, there are hundreds of image file types.[2] The PNG, JPEG, and GIF formats are most often used to display images on the Internet. These graphic formats are listed and briefly described below, separated into the two main families of graphics: raster and vector.

In addition to straight image formats, Metafile formats are portable formats which can include contain both raster and vector information. Examples are application-independent formats such as WMF and EMF. The metafile format is an intermediate format. Most Windows applications open metafiles and then save them in their own native format.[3][4] Page description language refers to formats used to describe the layout of a printed page containing text, objects and images. Examples are PostScript, PDF and PCL.

Raster formats

These formats store images as bitmaps (also known as pixmaps). For a description of the technology aside from the format, see Raster graphics.

JPEG

JPEG (Joint Photographic Experts Group) files are (in most cases) a lossy format; the DOS filename extension is JPG (other operating systems may use JPEG). Nearly every digital camera can save images in the JPEG format, which supports 8 bits per color (red, green, blue) for a 24-bit total, producing relatively small files. When not too great, the compression does not noticeably detract from the image's quality, but JPEG files suffer generational degradation when repeatedly edited and saved. Photographic images may be better stored in a lossless non-JPEG format if they will be re-edited, or if small "artifacts" (blemishes caused by the JPEG's compression algorithm) are unacceptable. The JPEG format also is used as the image compression algorithm in many Adobe PDF files.

The Exif (Exchangeable image file) format is an algorithm incorporated in the JPEG software used in most cameras. Its purpose is to record and to standardize the exchange of data between digital cameras and editing and viewing software. The data is recorded for individual images and includes such things as: camera settings, time and date, shutter speed, exposure, image size, compression, name of camera, color information, etc. When images are viewed or edited by image editors, such as Paint Shop Pro, all of this image information can be displayed.

TIFF

The TIFF (Tagged Image File Format) is a flexible format that normally saves 8 bits or 16 bits per color (red, green, blue) for 24-bit and 48-bit totals, respectively, using either the TIFF or the TIF filenames. The TIFF's flexibility is both blessing and curse, because no single reader reads every type of TIFF file. TIFFs are lossy and lossless; some offer relatively good lossless compression for bi-level (black&white) images. Some digital cameras can save in TIFF format, using the LZW compression algorithm for lossless storage. The TIFF image format is not widely supported by web browsers. TIFF remains widely accepted as a photograph file standard in the printing business. The TIFF can handle device-specific colour spaces, such as the CMYK defined by a particular set of printing press inks. OCR (Optical Character Recognition) software packages commonly generate some (often monochromatic) form of TIFF image for scanned text pages.

RAW

RAW refers to a family of raw image formats that are options available on some digital cameras. These formats usually use a lossless or nearly-lossless compression, and produce file sizes much smaller than the TIFF formats of full-size processed images from the same cameras. The raw formats are not standardized or documented, and differ among camera manufacturers. Many graphic programs and image editors may not accept some or all of them, and some older ones have been effectively orphaned already. Adobe's Digital Negative specification is an attempt at standardizing a raw image format to be used by cameras, or for archival storage of image data converted from proprietary raw image formats.

PNG

The PNG (Portable Network Graphics) file format was created as the free, open-source successor to the GIF. The PNG file format supports truecolor (16 million colors) while the GIF supports only 256 colors. The PNG file excels when the image has large, uniformly colored areas. The lossless PNG format is best suited for editing pictures, and the lossy formats, like JPG, are best for the final distribution of photographic images, because JPG files are smaller than PNG files. Many older browsers currently do not support the PNG file format, however, with Mozilla_Firefox or Internet Explorer 7, all contemporary web browsers now support all common uses of the PNG format, including full 8-bit translucency (Internet Explorer 7 may display odd colors on translucent images ONLY when combined with IE's opacity filter). The Adam7-interlacing allows an early preview, even when only a small percentage of the image data has been transmitted. PNG, an extensible file format for the lossless, portable, well-compressed storage of raster images. PNG provides a patent-free replacement for GIF and can also replace many common uses of TIFF. Indexed-color, grayscale, and truecolor images are supported, plus an optional alpha channel. PNG is designed to work well in online viewing applications, such as the World Wide Web, so it is fully streamable with a progressive display option. PNG is robust, providing both full file integrity checking and simple detection of common transmission errors. Also, PNG can store gamma and chromaticity data for improved color matching on heterogeneous platforms.

GIF

GIF (Graphics Interchange Format) is limited to an 8-bit palette, or 256 colors. This makes the GIF format suitable for storing graphics with relatively few colors such as simple diagrams, shapes, logos and cartoon style images. The GIF format supports animation and is still widely used to provide image animation effects. It also uses a lossless compression that is more effective when large areas have a single color, and ineffective for detailed images or dithered images.

BMP

The BMP file format (Windows bitmap) handles graphics files within the Microsoft Windows OS. Typically, BMP files are uncompressed, hence they are large; the advantage is their simplicity, wide acceptance, and use in Windows programs.

PPM, PGM, PBM, PNM

Netpbm format is a family including the portable pixmap file format (PPM), the portable graymap file format (PGM) and the portable bitmap file format (PBM). These are ASCII files that provide very basic functionality and serve as a lowest-common-denominator for converting pixmap, graymap, or bitmap files between different platforms. Several applications refer to them collectively as the PNM format (portable anymap).

Vector formats

As opposed to the raster image formats above (where the data describes the characteristics of each individual pixel), vector image formats contain a geometric description which can be rendered smoothly at any desired display size.

Vector file formats can contain bitmap data as well. 3D graphic file formats are technically vector formats with pixel data texture mapping on the surface of a vector virtual object, warped to match the angle of the viewing perspective.

At some point, all vector graphics must be rasterized in order to be displayed on digital monitors. However, vector images can be displayed with analog CRT technology such as that used in some electronic test equipment, medical monitors, radar displays, laser shows and early video games. Plotters are printers that use vector data rather than pixel data to draw graphics.

CGM

CGM (Computer Graphics Metafile) is a file format for 2D vector graphics, raster graphics, and text, and is defined by ISO/IEC 8632. All graphical elements can be specified in a textual source file that can be compiled into a binary file or one of two text representations. CGM provides a means of graphics data interchange for computer representation of 2D graphical information independent from any particular application, system, platform, or device. It has been adopted to some extent in the areas of technical illustration and professional design, but has largely been superseded by formats such as SVG and DXF.

SVG

SVG (Scalable Vector Graphics) is an open standard created and developed by the World Wide Web Consortium to address the need (and attempts of several corporations) for a versatile, scriptable and all-purpose vector format for the web and otherwise. The SVG format does not have a compression scheme of its own, but due to the textual nature of XML, an SVG graphic can be compressed using a program such as gzip. Because of its scripting potential, SVG is a key component in web applications: interactive web pages that look and act like applications.

ODG

ODG (Open Document Graphics) is an open standard.


Others

Other image file formats of vector type include:

References

  1. ^ NOTE: These two images are illustrative only, both were converted from a lossless, compressed RAW image in Adobe Photoshop CS2. The lossy image was repeatedly opened and resaved using a low JPEG quality setting to increase visual artifacting and then exported as a PNG, while the "lossless" image was saved once as a PNG to minimize visual artifacting.
  2. ^ Image File Types
  3. ^ MSDN: Windows Metafile Format Specification
  4. ^ MSDN: Enhanced Metafile Format Specification

See also

External links