Компьютерный форум OSzone.net  

Компьютерный форум OSzone.net (http://forum.oszone.net/index.php)
-   Вебмастеру (http://forum.oszone.net/forumdisplay.php?f=22)
-   -   [решено] imagecreatefrompng прицепить php скрпит вместо png (http://forum.oszone.net/showthread.php?t=333115)

LaFleur 11-02-2018 22:38 2797401

imagecreatefrompng прицепить php скрпит вместо png
 
Всем привет!
Делаю диаграммы используя pChart.

HTML код:

<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Statistics</title>
</head>
<div id="image" style="position: relative;">
<img src="Donut1.php" align="left" style="position:absolute;left:0px;right:100px;top:130px;""></img>
</div>
</html>

Donut1.php:
PHP код:

<?php
/* pChart library inclusions */
include("/var/www/html/class/pData1.class.php");
include(
"/var/www/html/class/pDraw1.class.php");
include(
"/var/www/html/class/pPie1.class.php");
include(
"/var/www/html/class/pImage1.class.php");

/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints(array(2,3,12,28,55,0,0,0),"ScoreA");
$MyData->setSerieDescription("ScoreA","Application A");

/* Define the absissa serie */
$MyData->addPoints(array("text","text","text","text","text","text","text","text","text","text"),"Labels");
$MyData->setAbscissa("Labels");

/* Create the pChart object */
$myPicture = new pImage(890,500,$MyData);

/* Set the default font properties */
$myPicture->setFontProperties(array("FontName"=>"/var/www/html/fonts/arial.ttf","FontSize"=>14,"R"=>80,"G"=>80,"B"=>80));

/* Create the pPie object */
$PieChart = new pPie($myPicture,$MyData);

/* Draw an AA pie chart */
$PieChart->draw2DRing(330,260,array("DrawLabels"=>TRUE,"LabelStacked"=>TRUE,"Border"=>FALSE));

/* Render the picture (choose the best way) */
$myPicture->autoOutput("draw2DRing.png");
?>

Но к сожалению выводится картинками. В общем при выводе изображения в html понадобилось избавиться от фона. Вырезать диаграмму. Нашёл рабочее решение:

PHP код:

<?php
$img 
imagecreatefrompng();
$white imagecolorexact($img255255255);
imagecolortransparent($img$white);
header("Content-Type: image/png");
imagepng($img);
?>

Правда не знаю как подцепить его к моему php скрипту, ведь нужен физический png файл.
Подскажите пожалуйста как можно такую вещь реализовать. Может как-то в html прицепить эти два скрипта, но при этом что бы один скрипт проходил через другой. Или imagecreatefrompng использовать как функцию которой не нужен будет png файл.
Ребята, нужен ваш опыт)

LaFleur 12-02-2018 01:33 2797431

Получилось.

PHP код:

ob_start();
$myPicture->autoOutput('/var/www/html/'.$image.'.png');
$image ob_get_contents();
ob_end_clean();
$file fopen('123.png''wb');
fputs($file$image);
fclose($file); 



Время: 10:13.

Время: 10:13.
© OSzone.net 2001-