I cribbed this script from the PHP manual, but I get no graphic, and no errors.
Have I done something wrong?
(this is is run as a function, and not in the main php file)
header("Content-type: image/jpeg");
$img = imagecreatetruecolor(100,100);
// $colors = chart_GenColors($img, sizeof($angle));
$colors[0] = imagecolorallocate($img, 0, 0, 102);
$colors[1] = imagecolorallocate($img, 0, 102, 0);
$colors[2] = imagecolorallocate($img, 102, 0, 0);
for ($i = 60; $i > 50; $i--)
{
imagefilledarc($img, 50, $i, 100, 50, 0, 45, $colors[0], IMG_ARC_PIE);
imagefilledarc($img, 50, $i, 100, 50, 45, 75 , $colors[1], IMG_ARC_PIE);
imagefilledarc($img, 50, $i, 100, 50, 75, 360 , $colors[2], IMG_ARC_PIE);
}
imagefilledarc($img, 50, 50, 100, 50, 0, 45, $colors[0], IMG_ARC_PIE);
imagefilledarc($img, 50, 50, 100, 50, 45, 75 , $colors[1], IMG_ARC_PIE);
imagefilledarc($img, 50, 50, 100, 50, 75, 360 , $colors[2], IMG_ARC_PIE);
header("Content-type: image/jpeg");
imagejpeg($img);
imagedestroy($img);Horus_Kol,
I tried your code and it worked.
Here is the code I used, just copied from your post:
<?php
header("Content-type: image/jpeg");
$img = imagecreatetruecolor(100,100);
// $colors = chart_GenColors($img, sizeof($angle));
$colors[0] = imagecolorallocate($img, 0, 0, 102);
$colors[1] = imagecolorallocate($img, 0, 102, 0);
$colors[2] = imagecolorallocate($img, 102, 0, 0);
for ($i = 60; $i > 50; $i--)
{
imagefilledarc($img, 50, 10, 100, 50, 0, 45, $colors[0], IMG_ARC_PIE);
imagefilledarc($img, 50, 20, 100, 50, 45, 75 , $colors[1], IMG_ARC_PIE);
imagefilledarc($img, 50, 30, 100, 50, 75, 360 , $colors[2], IMG_ARC_PIE);
}
imagefilledarc($img, 50, 50, 100, 50, 0, 45, $colors[0], IMG_ARC_PIE);
imagefilledarc($img, 50, 50, 100, 50, 45, 75 , $colors[1], IMG_ARC_PIE);
imagefilledarc($img, 50, 50, 100, 50, 75, 360 , $colors[2], IMG_ARC_PIE);
header("Content-type: image/jpeg");
imagejpeg($img);
imagedestroy($img);
?>
The output is here:
<!-- m --><a class="postlink" href="http://marineemlab.ucsd.edu/CSEM/gdxperi/test.php">http://marineemlab.ucsd.edu/CSEM/gdxperi/test.php</a><!-- m -->
What version of GD are you using - what does the GD section in your phpinfo() function say?Here is what my GD config looks like:
gd
GD Support enabled
GD Version bundled (2.0.15 compatible)
FreeType Support enabled
FreeType Linkage with freetype
T1Lib Support enabled
GIF Read Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabledpport enabled
GD Version 1.6.2 or higher
FreeType Support enabled
FreeType Linkage with freetype
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
It doesn't look too good though does it...
Prolly using the wrong colours.
how are you placing this in your script
i have one script which has the layout of the page, and then I call a function call PieChart out of a different file.
Is this the problem?I just copied your code into a stand-alone script (which I pasted in my intial reply). It worked fine.
Your GD config looks okay.
Lets have a look-see at your PieChart function - maybe it is something in that?that is my pie-chart function at the moment...it has to be its own stand alone file, and it has to be done through an <img /> tag unless you just give a link to it. so if you arent doing that, its not going to work.
and when i say stand alone file. it doesnt necessarily have to be in its own file, just only that can be outputted. no other text or anything.
Have I done something wrong?
(this is is run as a function, and not in the main php file)
header("Content-type: image/jpeg");
$img = imagecreatetruecolor(100,100);
// $colors = chart_GenColors($img, sizeof($angle));
$colors[0] = imagecolorallocate($img, 0, 0, 102);
$colors[1] = imagecolorallocate($img, 0, 102, 0);
$colors[2] = imagecolorallocate($img, 102, 0, 0);
for ($i = 60; $i > 50; $i--)
{
imagefilledarc($img, 50, $i, 100, 50, 0, 45, $colors[0], IMG_ARC_PIE);
imagefilledarc($img, 50, $i, 100, 50, 45, 75 , $colors[1], IMG_ARC_PIE);
imagefilledarc($img, 50, $i, 100, 50, 75, 360 , $colors[2], IMG_ARC_PIE);
}
imagefilledarc($img, 50, 50, 100, 50, 0, 45, $colors[0], IMG_ARC_PIE);
imagefilledarc($img, 50, 50, 100, 50, 45, 75 , $colors[1], IMG_ARC_PIE);
imagefilledarc($img, 50, 50, 100, 50, 75, 360 , $colors[2], IMG_ARC_PIE);
header("Content-type: image/jpeg");
imagejpeg($img);
imagedestroy($img);Horus_Kol,
I tried your code and it worked.
Here is the code I used, just copied from your post:
<?php
header("Content-type: image/jpeg");
$img = imagecreatetruecolor(100,100);
// $colors = chart_GenColors($img, sizeof($angle));
$colors[0] = imagecolorallocate($img, 0, 0, 102);
$colors[1] = imagecolorallocate($img, 0, 102, 0);
$colors[2] = imagecolorallocate($img, 102, 0, 0);
for ($i = 60; $i > 50; $i--)
{
imagefilledarc($img, 50, 10, 100, 50, 0, 45, $colors[0], IMG_ARC_PIE);
imagefilledarc($img, 50, 20, 100, 50, 45, 75 , $colors[1], IMG_ARC_PIE);
imagefilledarc($img, 50, 30, 100, 50, 75, 360 , $colors[2], IMG_ARC_PIE);
}
imagefilledarc($img, 50, 50, 100, 50, 0, 45, $colors[0], IMG_ARC_PIE);
imagefilledarc($img, 50, 50, 100, 50, 45, 75 , $colors[1], IMG_ARC_PIE);
imagefilledarc($img, 50, 50, 100, 50, 75, 360 , $colors[2], IMG_ARC_PIE);
header("Content-type: image/jpeg");
imagejpeg($img);
imagedestroy($img);
?>
The output is here:
<!-- m --><a class="postlink" href="http://marineemlab.ucsd.edu/CSEM/gdxperi/test.php">http://marineemlab.ucsd.edu/CSEM/gdxperi/test.php</a><!-- m -->
What version of GD are you using - what does the GD section in your phpinfo() function say?Here is what my GD config looks like:
gd
GD Support enabled
GD Version bundled (2.0.15 compatible)
FreeType Support enabled
FreeType Linkage with freetype
T1Lib Support enabled
GIF Read Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabledpport enabled
GD Version 1.6.2 or higher
FreeType Support enabled
FreeType Linkage with freetype
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
It doesn't look too good though does it...
Prolly using the wrong colours.
how are you placing this in your script
i have one script which has the layout of the page, and then I call a function call PieChart out of a different file.
Is this the problem?I just copied your code into a stand-alone script (which I pasted in my intial reply). It worked fine.
Your GD config looks okay.
Lets have a look-see at your PieChart function - maybe it is something in that?that is my pie-chart function at the moment...it has to be its own stand alone file, and it has to be done through an <img /> tag unless you just give a link to it. so if you arent doing that, its not going to work.
and when i say stand alone file. it doesnt necessarily have to be in its own file, just only that can be outputted. no other text or anything.