# Get Size Of Images

Specifying the desired size of an image in its `<IMG>` tag can speed up the browser's layout because the browser doesn't have to wait for the image to be transfered or needs to re-layout the page after the transfer. `hsc` can either add `WIDTH` and `HEIGHT` attributes to the tag or use Cascading Stylesheet specifications to add the size information.

## Usage

As you usually don't know the exact size of your images, let your stupid computer handle this dull task by enabling the switch `GetSize` when invoking `hsc`. This tells `hsc` to analyse the image the attribute `SRC` refers to, and either append the attributes `WIDTH` and `HEIGHT` with the dimensions obtained from the image data, oder add the properties `width:` and `height:` to a `STYLE` attribute, which will be created if it didn't exist yet.

If you have already set these attributes yourself, `hsc` will only validate the values, and warn about mismatches.

## Example

Take a look at this nice picture of some nice guy:

This can usually be included in a document using something like

    <img SRC="image/niceguy.png" ALT="Picture of some nice guy">

but if a document called niceguy.hsc containing such a tag is converted using

    hsc niceguy.hsc TO niceguy.html GETSIZE

the `<IMG>`-tag seen above will be extended to

    <img SRC="image/niceguy.png" ALT="Picture of some nice guy" WIDTH="64" HEIGHT="64">

in the HTML object. If you do not like the double quotes assigned to the size values, use the commandline option `QuoteStyle` to change this behavior.

The use of STYLE attributes is currently tied to the XHTML mode, i.e. XHTML output will use CSS while traditional HTML uses the `WIDTH` and `HEIGHT` attributes. The above example would look like this after running it through `hsc` with XHTML enabled:

    <img SRC="image/niceguy.png" ALT="Picture of some nice guy" STYLE="width:64px; height:64px">

## Supported Image Formats

In the recent years several formats to store image data have been established — mostly because none of these was really useful. Only a few of them are supported by `hsc`. However, these should be enough for w3-authoring.

### gif — Graphics Interchange Format

In the early times of w3, this was the only format supported by most browsers. It features only indexed-color (16 or 256 colors) and an ugly looking progressive display option. It became very popular in a negative sense because of it's compression algorithm and the associated copyright.

Bye the way, did you know that "The Graphics Interchange Format(c) is the Copyright property of CompuServe Incorporated. GIF(sm) is a Service Mark property of CompuServe Incorporated."? So now you do; if it makes them happy...

### jfif/jpeg

Essentially, this format does a good job as an idiot indicator. This already starts with the name: jfif is short for JPEG File Interchange Format (because it uses jpeg compression for image data). Nevertheless jfif-pictures will have a file extension set to ```.jpg`'' or ```.jpeg`''.

The main feature about jpeg compression is that it is lossy, which means that the output image is not identical to the input image. Documents about software using jpeg compression usually claim that you can obtain good compression levels with no visible change. As long as you do not start to rotate or apply other complex image processing operations on pictures, this might even be true. Otherwise, an ugly grid will appear soon.

Most important, jfif is commonly used to encode images of more or less undressed people. To store as many such pictures as possible in as little space as possible, the compression rate is usually set to a high value. This makes these people look as if they suffered from leprosy, or just a drawing by Egon Schiele.

Furthermore many people outside English speaking countries pronounce jpeg (``jay-peg'') as GPEG (``gee-peg''), even if they are normally capable of a proper English pronunciation.

### PNG — Portable Network Graphics

The PNG Specification (http://www.w3.org/pub/WWW/TR/WD-png) claims this format to be

> ...an extensible file format for the lossless, portable, well-compressed storage of raster images. PNG provides a patent-free replacement for the GIF format and can also replace many common uses of TIFF format. Indexed-color, grayscale, and truecolor images are supported, plus an optional alpha channel. Sample depths range from 1 to 16 bits [and] it is fully streamable with a progressive display option.

Above all, PNG supports most obvious things several other formats failed to include. There is nothing really remarkable about it, but today one has to be glad even about this. So it can be said that PNG is one of the few positive things that happened in the last ten years.

But even despite there being free source code available to read PNG-images, and the word ``Network'' is part of it's name (to conform to the hype), it was only supported by very few applications and w3-browsers for a long time. This slowly changes, so maybe you will want to give it a try.

Bye the way, `hsc` has always supported it — actually it was the first working image format because it took some releases to end up with a bugfree scanner for gif...