You are here: Re: Image Creation « PHP « IT news, forums, messages
Re: Image Creation

Posted by Aaron Todd on 10/01/65 11:08

Thanks for the compliment on my function. I have since improved upon
it...see below.

I can do the exact same thing as you and get results, but what I can't do is
show the image within an HTML table. I think it is something to do with the
header line, but I dont know how to get around it. I've tried just calling
the function like I have in the code below. I've also tried calling the
function inside of <img> command. Both ways dont work.

Check out the code if you can and let me know if you seen anything that I am
doing wrong. Thanks

<?php
function makepie($slice, $total){
$height = 150;
$width = 150;
$im = ImageCreate($width, $height);
$bck = ImageColorAllocate($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0, 0, 0);
$white = ImageColorAllocate($im, 255, 255, 255);
$red = ImageColorAllocate($im, 255, 0, 0);
$blue = ImageColorAllocate($im, 0, 0, 255);
//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, $blue,
IMG_ARC_PIE);
imagefilledarc($im, 75, 75, 125, 125, 315, $pieslice, $black,
IMG_ARC_NOFILL);
imagefilledarc($im, 75, 75, 125, 125, $pieslice, 315, $red,
IMG_ARC_PIE);
imagefilledarc($im, 75, 75, 125, 125, $pieslice, 315, $black,
IMG_ARC_NOFILL);

//Return
Header("Content-type: image/png");
ImagePNG($im);
}
echo "<table border='1' cellpadding='0' cellspacing='0'
style='border-collapse: collapse' bordercolor='#111111' width='200'
bgcolor='#FFD1A4'>
<tr>
<td width='100%' colspan='2' align='center'>This is a
test<br>".makepie(20,200)."</td>
</tr>
</table>";
?>




"James Taylor" <james.taylor@stealthnet.net> wrote in message
news:20050215152739.24688.qmail@lists.php.net...
> Dude - that works fine!
>
> can you check your code - make sure you havnt got any white space at all
> before the php starts in ANY file, and then check that you've got ALL
> erros being reported (because you might have the error cant send headers,
> output allready sent at line x) which will prenvent the header being sent
> and then you dump the image to the screen which is the random wierd
> characters (that means the image create functions are all ok and
> installed, and you have an image object or similar).
>
> my code was simple <?php {your function} makepie(10,100); ?> NO WHITESPACE
> NO BLANK LINES NOTHING.
>
> (ps you might even have a php include in the php file (php prepend or
> something?) which might be inserting a space or a newline or ending
> headers or something. Look at error_reporting() or similar in the manual
> to turn error reporting on for your script.
>
> Hope you find the bug, thats quite a nice function you have there.
> J
>
> Aaron Todd wrote:
>> 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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация