我正在使用以下内容:
$chartImage->autoOutput('/statistics/'.$image.'.png');
问题是这段代码将图像输出到浏览器。如果它将图像保存到具有我指定的目录和名称的文件中,我会更喜欢它。我该怎么做呢?我正在查看 pChart wiki,它与所有这些 pCache 内容非常混淆。我不需要任何缓存或类似的东西......我只想保存图像。
尝试使用:
$chartImage->render("image_name.png");
它在 1.x 中对我有用,不知道 2.x - 没有使用它。
如果没有办法,那就做
ob_start();
$chartImage->autoOutput('/statistics/'.$image.'.png');
$image = ob_get_contents();
ob_end_clean();
$file = fopen('<path_to_file>', 'wb');
fputs($file, $image);
fclose($file);
$imageOut = 'grafico';
$chart->drawFromJPG($width, $height, "{$imageOut}.jpg");
$chart->render("{$imageOut}.jpg");
我把这个工作得很好。