| 
<?php
 /* example usage of Image class */
 include 'image.class.php';
 
 /* if the file already exists just open it rather than regenerate it */
 if (file_exists('myimage.png')) {
 $img = new Image('myimage.png');
 }else{
 /* create a new image 600 pixels wide by 400 pixels high */
 $img = new Image(false,600,400);
 
 /* set the brush colors */
 /* black background */
 $img->set_bgcolor(0,0,0);
 /* red foreground */
 $img->set_fgcolor(255,0,0);
 
 /* fill the image with the back groundcolour */
 $img->fill('bg');
 
 /* draw a line diagonally across the image */
 $img->draw_line(0,0,600,400);
 
 /* change the foreground color to green */
 $img->set_fgcolor(0,255,0);
 
 /*
 * draw a filled rectangle at 100 pixels from the top and left
 * with a width of 200 pixels and a height of 50 pixels
 * at a 20 degree angle
 */
 $img->draw_rect(100,100,200,50,20);
 
 /* set a thicker brush width */
 $img->set_brush_width(10);
 
 /* draw a new line crossing the first one */
 $img->draw_line(600,0,0,400);
 
 /* apply a blue transparent filter to the image */
 $img->filter_colorize(0,0,255,64);
 
 /* add a gaussian blur */
 $img->filter_gaussianblur();
 
 /* and lower the brightness */
 $img->filter_brightness(50);
 
 /* save the image to file for reuse */
 $img->save('myimage.png');
 }
 
 /* and output to the browser */
 $img->output();
 
 ?>
 
 |