Contents Previous Next

## 4.6 Alternatives to streaming back the image

If you like to save the image directly to a file instead of streaming it back to the browser then you just have to specify an absolute filename in the final call to Graph::Stroke(), i.e.

`$graph-> Stroke( "/usr/home/peter/images/result2002.png");`

Please note that the user running as Apache/PHP must have write access to the specified directory.

There are also two predefined filenames which have special meaning.

- "auto", This will create a file in the same directory as the script with the same name as the script but with the correct image extension.
- __IMG_HANDLER, (This is defined in jpgraph.php). Specifying this filename will not create a an image to file or stram it back to the browser. Instead it will instruct the Stroke() method to just return the handle for the GD image. This is useful if you later want to manipulate the image in ways that are not yet supported by Jpgraph. For example include the image in generated PDF files.
  Example:
  `$handle = $graph->Stroke(__IMG_HANDLER );`

Contents Previous Next