|
Posted by James Taylor on 10/04/02 11:08
Ahh now it becomes clear, you where trying to place the image inline.
There is a way with base64 encoding, but it isnt supported by many
browsers - you can actually say <IMG SRC="data:image/png,base64;[...]">
where the [...] is the base64 encoded image, so you would need to wrap
an ob start and ob end around your code to catch output, then base64
encode it then display it.
The problem is it dosnt work in IE because IE dosn't support this. Its
also not very nice for anyone not wanting to view images as they will
have downloaded the image even though they dont want to see it. There
was a very good reason why I know that and have done it, but more then
99.9% of the time, its not the way to go.
(the case in example was an embedded application on a machine that had a
pseudo-web interface but no webserver - it would wait for a connection
on a port then "dump" a stream of text which would be in HTML - there
was no webserver there it would ignore any http headers sent).
Aaron Todd wrote:
> 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
[Back to original message]
|