Usage: Advanced

If you have worked with HAMweather much, you have realized how easy it is to customize it by simply editing templates.  Well to keep the same power of customization, HWimage has a slightly more advanced mode of operation that allows you to have HWimage create totally customized images.  These customized images are based on HWimage template files that you make.  With the advanced mode of HWimage, the weather information graphics that can be created are endless, your imagination (OK.. and server resources) are your limit!

To use HWimage in the advanced mode, you simply use HWimage as stated in the Basic mode, except there is one additional parameter to provide, the 'img' parameter.  This parameter tells HWimage to load the specified template and create an image based on the template.

<img src='http://www.yourdomain.com/cgi-bin/weather/hwimage.cgi?forecast=zone&state=va&place=blacksburg&img=ex1'>

The 'img=ex1' tells HWimage that once the forecast info is fetched to use the HWimage template named 'ex1.txt' to generate the image.

So now you wonder... What do the HWimage template files look like.  Below is an example of a real simple HWimage template file followed by an explanation:

size 200 100
background RGB 255 255 255
textcolor RGB 0 0 0
textsize MEDIUM
textwrap 25
textat 0 0 "%%zforecast%%"

When looking at the template above, notice that it uses simple commands to set the various attributes of the image.  Also note the use of '%%zforecast%%'.  the template files can use any of the template variables used by normal HAMweather template plus a few additional ones as well. You can view a list of all the template variables available on the template variables page.

What the above template does is create an image 200 by 100 pixels that has a white background and includes the forecast text.  A brief explanation of the actual template lines follows:

Line Description
size 200 100 Set the initial image size to 200 pixels by 100 pixels.
background RGB 255 255 255 Set the image background color to the RGB values of 255 255 255 (white).  This line could have easily been written as:

background white
or even
background RGBH FFFFFF

textcolor RGB 255 255 255 Set the color to use when drawing text in the image to black. This line coudl have also been written as:

textcolor BLACK
or even
textcolor RGBH 000000

textwrap 25 Set the maximum number of characters for wordwrapping to 25.
textat 0 0 "%%zforecast%%" The %%zforecast%% will be replaced by the actual text forecast and then the text will be drawn in the image starting at coordinate (0,0)

To view more examples of template Check out the Template Examples page.

For a complete list of the HWimage template commands visit the Template Command Page and for information about the general syntax of the HWimage templates visit the Template Syntax page.