undefined function: imagecreatetruecolor
Posted: Sun Jan 22, 2006 1:21 pm
hawleyjr | Please use
(The error is similar if I use imagecreate)
I am new to PHP and Unix. The server administrator tells me nothing has changed on the server.
Please advise me on what steps need to be done to get this sample code running again on a Unix server.
Also, looking ahead, I'd like to use GD to creat the image embedded in a page that I have output HTML, then the image, then more HTML. Since the example uses header("Content-type: image/png"); I know I can't just nest it in an series of echo commands outputting HTML and text. Any help on the general solution for that is also appreciated.
This work is for an Oakland University research project that will allow field biologists in South America to enter in parameters defining villages and get back a predictive model of the spread of Chagas Disease based on spraying applications.
Code --------------------------------------------
hawleyjr | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I am working with GD on a Unix server. Using [url]http://www.php.net/manual/en/ref.image.php[/url] as my guide I created a file called linechart.php with the code below. I uploaded the file and it worked fine. I noted among the changes I wanted to make was a brighter background to get more contrast. After some time passed and I returned to the project, running the unchanged file at [url]http://gauss.math.oakland.edu/chagas/linechart.php[/url] gives the error:Code: Select all
<br />
<b>Fatal error</b>: Call to undefined function: imagecreatetruecolor() in <b>/usr/local/www/data-dist/chagas/linechart.php</b> on line <b>12</b><br />I am new to PHP and Unix. The server administrator tells me nothing has changed on the server.
Please advise me on what steps need to be done to get this sample code running again on a Unix server.
Also, looking ahead, I'd like to use GD to creat the image embedded in a page that I have output HTML, then the image, then more HTML. Since the example uses header("Content-type: image/png"); I know I can't just nest it in an series of echo commands outputting HTML and text. Any help on the general solution for that is also appreciated.
This work is for an Oakland University research project that will allow field biologists in South America to enter in parameters defining villages and get back a predictive model of the spread of Chagas Disease based on spraying applications.
Code --------------------------------------------
Code: Select all
<?
// Add values to the graph
$graphValues=array(0,80,23,11,190,245,50,80,111,240,55);
// Define .PNG image
header("Content-type: image/png");
$imgWidth=250;
$imgHeight=250;
// Create image and define colors
//$image=imagecreate($imgWidth, $imgHeight);
$image=imagecreatetruecolor($imgWidth, $imgHeight);
$colorWhite=imagecolorallocate($image, 255, 255, 255);
$colorGrey=imagecolorallocate($image, 192, 192, 192);
$colorBlue=imagecolorallocate($image, 0, 0, 255);
// Create border around image
imageline($image, 0, 0, 0, 250, $colorGrey);
imageline($image, 0, 0, 250, 0, $colorGrey);
imageline($image, 249, 0, 249, 249, $colorGrey);
imageline($image, 0, 249, 249, 249, $colorGrey);
// Create grid
for ($i=1; $i<11; $i++){
imageline($image, $i*25, 0, $i*25, 250, $colorGrey);
imageline($image, 0, $i*25, 250, $i*25, $colorGrey);
}
// Create line graph
for ($i=0; $i<10; $i++){
imageline($image, $i*25, (250-$graphValues[$i]), ($i+1)*25, (250-$graphValues[$i+1]), $colorBlue);
}
// Output graph and clear image from memory
imagepng($image);
imagedestroy($image);
?>Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]