RE: [PHP] image_create(), header.....
You can save them and then call them up, but then you have to use a cron or something to empty out the folder. Here's how I save it: //Image created and everything up here, this is the very end of it $myTime = time(); ImagePNG($im, ../spool/jp$myTime.png); //this creates a unique name chmod(../spool/jp$myTime.png, 0666); //leading 0, then the code for the mode you want ImageDestroy($im); print img src='../spool/jp$myTime.png' border=0 width=\520\ GALLERYIMG=\NO\ height=\500\/td; I hope this helps! -Natalie -Original Message- From: Gerard Samuel [mailto:[EMAIL PROTECTED]] Sent: Friday, May 24, 2002 2:37 PM To: PHP Subject: [PHP] image_create(), header. Im trying to use dynamic buttons, and Im trying to figure out how to get around the header call. I figure use output buffering, but so far Ive only come up with errors. Anyone see a better way or any errors in my code. Thanks nb: Uncomment the echo() statement to get the error. -- ?php //echo 'Heybr'; function button($word) { ob_start(); header(Content-Type: image/png); $im = ImageCreate(100, 50); $black = ImageColorAllocate($im, 0, 0, 0); $white = ImageColorAllocate($im, 255, 255, 255); $start_x = 50 - (strlen($word) * ImageFontWidth(5) / 2); $start_y = 25 - ImageFontHeight(5) / 2; ImageString($im, 5, $start_x, $start_y, $word, $white); ImagePNG($im); ImageDestroy($im); ob_end_flush(); } button('Hello World'); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] image_create(), header.....
Thanks! I didn't know it was that helpful :-) It's in there now. -Natalie -Original Message- From: Boaz Yahav [mailto:[EMAIL PROTECTED]] Sent: Friday, May 24, 2002 3:58 PM To: Leotta, Natalie (NCI/IMS) Subject: RE: [PHP] image_create(), header. This looks like a great example to add to weberdev. would you care to spend 3 minutes and let other PHP developers enjoy from your knowledge? You are one click away from doing a good deed :) http://www.weberdev.com/index.php3?GoTo=addexample.php3 Sincerely berber Visit http://www.weberdev.com Today!!! To see where PHP might take you tomorrow. -Original Message- From: Leotta, Natalie (NCI/IMS) [mailto:[EMAIL PROTECTED]] Sent: Friday, May 24, 2002 8:42 PM To: 'Gerard Samuel'; PHP Subject: RE: [PHP] image_create(), header. You can save them and then call them up, but then you have to use a cron or something to empty out the folder. Here's how I save it: //Image created and everything up here, this is the very end of it $myTime = time(); ImagePNG($im, ../spool/jp$myTime.png); //this creates a unique name chmod(../spool/jp$myTime.png, 0666); //leading 0, then the code for the mode you want ImageDestroy($im); print img src='../spool/jp$myTime.png' border=0 width=\520\ GALLERYIMG=\NO\ height=\500\/td; I hope this helps! -Natalie -Original Message- From: Gerard Samuel [mailto:[EMAIL PROTECTED]] Sent: Friday, May 24, 2002 2:37 PM To: PHP Subject: [PHP] image_create(), header. Im trying to use dynamic buttons, and Im trying to figure out how to get around the header call. I figure use output buffering, but so far Ive only come up with errors. Anyone see a better way or any errors in my code. Thanks nb: Uncomment the echo() statement to get the error. -- ?php //echo 'Heybr'; function button($word) { ob_start(); header(Content-Type: image/png); $im = ImageCreate(100, 50); $black = ImageColorAllocate($im, 0, 0, 0); $white = ImageColorAllocate($im, 255, 255, 255); $start_x = 50 - (strlen($word) * ImageFontWidth(5) / 2); $start_y = 25 - ImageFontHeight(5) / 2; ImageString($im, 5, $start_x, $start_y, $word, $white); ImagePNG($im); ImageDestroy($im); ob_end_flush(); } button('Hello World'); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image_create(), header.....
You need to put the ob_start() call at the very beginning of your script, not inside that function. You have to turn output buffering on before ANY output is generated, if you want to be able to send headers later on. miguel On Fri, 24 May 2002, Gerard Samuel wrote: Im trying to use dynamic buttons, and Im trying to figure out how to get around the header call. I figure use output buffering, but so far Ive only come up with errors. Anyone see a better way or any errors in my code. Thanks nb: Uncomment the echo() statement to get the error. -- ?php //echo 'Heybr'; function button($word) { ob_start(); header(Content-Type: image/png); $im = ImageCreate(100, 50); $black = ImageColorAllocate($im, 0, 0, 0); $white = ImageColorAllocate($im, 255, 255, 255); $start_x = 50 - (strlen($word) * ImageFontWidth(5) / 2); $start_y = 25 - ImageFontHeight(5) / 2; ImageString($im, 5, $start_x, $start_y, $word, $white); ImagePNG($im); ImageDestroy($im); ob_end_flush(); } button('Hello World'); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] image_create(), header.....
While Natalie's solution is a valid one, i have another first - the error you're getting is because the headers are sent AS SOON as you echo, print or output html outside of your ?php ? tags. you're echoing something before you call ob_start(); second- the reason this doesn't work, is because you're trying to write binary image bytes into an text html page I think what you want is something like this (actually 2 scripts): script1.php : ?php echo 'Heybr'; echo 'img src=script2.php?theword=Hello+World'; ? script2.php : ?php function button($word) { ob_start(); header(Content-Type: image/png); $im = ImageCreate(100, 50); $black = ImageColorAllocate($im, 0, 0, 0); $white = ImageColorAllocate($im, 255, 255, 255); $start_x = 50 - (strlen($word) * ImageFontWidth(5) / 2); $start_y = 25 - ImageFontHeight(5) / 2; ImageString($im, 5, $start_x, $start_y, $word, $white); ImagePNG($im); ImageDestroy($im); ob_end_flush(); } button($_GET[theword]); ? Original Message Follows From: Leotta, Natalie (NCI/IMS) [EMAIL PROTECTED] You can save them and then call them up, but then you have to use a cron or something to empty out the folder. Here's how I save it: //Image created and everything up here, this is the very end of it $myTime = time(); ImagePNG($im, ../spool/jp$myTime.png); //this creates a unique name chmod(../spool/jp$myTime.png, 0666); //leading 0, then the code for the mode you want ImageDestroy($im); print img src='../spool/jp$myTime.png' border=0 width=\520\ GALLERYIMG=\NO\ height=\500\/td; I hope this helps! -Natalie -Original Message- From: Gerard Samuel [mailto:[EMAIL PROTECTED]] Sent: Friday, May 24, 2002 2:37 PM To: PHP Subject: [PHP] image_create(), header. Im trying to use dynamic buttons, and Im trying to figure out how to get around the header call. I figure use output buffering, but so far Ive only come up with errors. Anyone see a better way or any errors in my code. Thanks nb: Uncomment the echo() statement to get the error. -- ?php //echo 'Heybr'; function button($word) { ob_start(); header(Content-Type: image/png); $im = ImageCreate(100, 50); $black = ImageColorAllocate($im, 0, 0, 0); $white = ImageColorAllocate($im, 255, 255, 255); $start_x = 50 - (strlen($word) * ImageFontWidth(5) / 2); $start_y = 25 - ImageFontHeight(5) / 2; ImageString($im, 5, $start_x, $start_y, $word, $white); ImagePNG($im); ImageDestroy($im); ob_end_flush(); } button('Hello World'); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image_create(), header.....
While Natalie's example, was doable, this one takes the cake for me. Thank you all for your suggestions Jerome Houston wrote: While Natalie's solution is a valid one, i have another first - the error you're getting is because the headers are sent AS SOON as you echo, print or output html outside of your ?php ? tags. you're echoing something before you call ob_start(); second- the reason this doesn't work, is because you're trying to write binary image bytes into an text html page I think what you want is something like this (actually 2 scripts): script1.php : ?php echo 'Heybr'; echo 'img src=script2.php?theword=Hello+World'; ? script2.php : ?php function button($word) { ob_start(); header(Content-Type: image/png); $im = ImageCreate(100, 50); $black = ImageColorAllocate($im, 0, 0, 0); $white = ImageColorAllocate($im, 255, 255, 255); $start_x = 50 - (strlen($word) * ImageFontWidth(5) / 2); $start_y = 25 - ImageFontHeight(5) / 2; ImageString($im, 5, $start_x, $start_y, $word, $white); ImagePNG($im); ImageDestroy($im); ob_end_flush(); } button($_GET[theword]); ? Original Message Follows From: Leotta, Natalie (NCI/IMS) [EMAIL PROTECTED] You can save them and then call them up, but then you have to use a cron or something to empty out the folder. Here's how I save it: //Image created and everything up here, this is the very end of it $myTime = time(); ImagePNG($im, ../spool/jp$myTime.png); //this creates a unique name chmod(../spool/jp$myTime.png, 0666); //leading 0, then the code for the mode you want ImageDestroy($im); print img src='../spool/jp$myTime.png' border=0 width=\520\ GALLERYIMG=\NO\ height=\500\/td; I hope this helps! -Natalie -Original Message- From: Gerard Samuel [mailto:[EMAIL PROTECTED]] Sent: Friday, May 24, 2002 2:37 PM To: PHP Subject: [PHP] image_create(), header. Im trying to use dynamic buttons, and Im trying to figure out how to get around the header call. I figure use output buffering, but so far Ive only come up with errors. Anyone see a better way or any errors in my code. Thanks nb: Uncomment the echo() statement to get the error. -- ?php //echo 'Heybr'; function button($word) { ob_start(); header(Content-Type: image/png); $im = ImageCreate(100, 50); $black = ImageColorAllocate($im, 0, 0, 0); $white = ImageColorAllocate($im, 255, 255, 255); $start_x = 50 - (strlen($word) * ImageFontWidth(5) / 2); $start_y = 25 - ImageFontHeight(5) / 2; ImageString($im, 5, $start_x, $start_y, $word, $white); ImagePNG($im); ImageDestroy($im); ob_end_flush(); } button('Hello World'); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php