Re: Image Creation
| From: | Aaron Todd | Date: | Tue, 15 Feb 2005 19:00:48 +0000 |
| Subject: | Re: Image Creation | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-208756@lists.php.net to get a copy of this message | ||
Hey Guys,
I think I fixed my own problem. I tried calling the PHP script from a
different page like this:
<img border='0' src='include/pie.php?slice=100&total=200'>
This gave me the results I wanted.
Thanks for all your help.
Aaron
"Aaron Todd" <aaloki88@hotmail.com> wrote in message
news:20050215130954.5387.qmail@lists.php.net...
>I just wrote a little script to play around with the GD library but I am
>having a problem displaying it in the browser. I have not problem at all
>when I just run the script. But I was trying to make the image in a custom
>function which will return the image when its called. All I end up getting
>is a bunch of weird characters.
>
> Here's my code:
> function makepie($slice, $total){
> $height = 150;
> $width = 150;
> $im = ImageCreate($width, $height);
> $bck = ImageColorAllocate($im, 255,255,255);
> $black = ImageColorAllocate($im, 0, 0, 0);
> $red = ImageColorAllocate($im, 255, 0, 0);
> imagefilledellipse($im, 75, 75, 125, 125, $red);
> imageellipse($im, 75, 75, 125, 125, $black);
>
> //Making the Slice
> $pieslice = (($slice / $total) * 360) + 315;
> imagefilledarc($im, 75, 75, 125, 125, 315, $pieslice, $black,
> IMG_ARC_PIE);
>
> //Return
> header("Content-type: image/png");
> echo ImagePNG($im);
> }
>
> Anyone have any idea why I cant return the image?
>
> Thanks