比如下面是某个使用JPgraph生成图片的文件:jp.php
<?php
include ("../jpgraph.php");
include ("../jpgraph_line.php");// Some data
$ydata = array(11,3,8,12,5,1,9,13,5,7);// Create the graph. These two calls are always required
$graph = new Graph(350,250,"auto");
$graph->SetScale("textlin");// Create the linear plot
$lineplot=new LinePlot($ydata);
$lineplot->SetColor("blue");// Add the plot to the graph
$graph->Add($lineplot);// Display the graph
$graph->Stroke();
?>我们都知道在其他页面使用<img src="jp.php"/>就可以显示这个图片,那么我想在生成这个图片时也把图片保存成jp.jpg或jp.png文件到images文件夹,请问各这要怎么做?
<?php
include ("../jpgraph.php");
include ("../jpgraph_line.php");// Some data
$ydata = array(11,3,8,12,5,1,9,13,5,7);// Create the graph. These two calls are always required
$graph = new Graph(350,250,"auto");
$graph->SetScale("textlin");// Create the linear plot
$lineplot=new LinePlot($ydata);
$lineplot->SetColor("blue");// Add the plot to the graph
$graph->Add($lineplot);// Display the graph
$graph->Stroke();
?>我们都知道在其他页面使用<img src="jp.php"/>就可以显示这个图片,那么我想在生成这个图片时也把图片保存成jp.jpg或jp.png文件到images文件夹,请问各这要怎么做?
或者你可以在类文件内添加一个函数,用imagejpeg等函数输出至文件
// $aStrokeFileName If != "" the image will be written to this file and NOT
// streamed back to the browser
function Stroke($aStrokeFileName="") {所以
$graph->Stroke("/tmp/test1.png");