Gruzin Posted March 30, 2007 Share Posted March 30, 2007 Hi guys, I'am haveing some trouble with GD images, the code (from phpfreaks) works just fine on windows, but it fails on Linux and I get something like this: ?PNG IHDR2?PLTE 鲿`?L.IDAT?c`??a??|(?Ҍ?3Υ??yێC鿐??ގӬS? ^od,;IEND?B`? here is the code: <?php header ("Content-type: image/png"); $img_handle = ImageCreate (230, 20) or die ("Cannot Create image"); $back_color = ImageColorAllocate ($img_handle, 0, 10, 10); $txt_color = ImageColorAllocate ($img_handle, 233, 114, 191); ImageString ($img_handle, 31, 5, 5, "My first Program with GD", $txt_color); ImagePng ($img_handle); ?> P.S I've checked phpinfo and GD Support is enabled. You help is very appreciated, George Link to comment https://forums.phpfreaks.com/topic/44893-gd-problem-with-linux/ Share on other sites More sharing options...
Full-Demon Posted March 30, 2007 Share Posted March 30, 2007 I know that linux is case sensitive...try it again where you have the functions written as: ImageCreate -> imagecreate ImagePng -> imagepng Can't think of other problems...you sure you installed the right GD lib from the repostorys (or whatever you spell that )? [depends on what distribution you use] apt-get install php5-gd and: [depends on what distribution you use] apt-get install php5-gd2 Full-Demon Link to comment https://forums.phpfreaks.com/topic/44893-gd-problem-with-linux/#findComment-218015 Share on other sites More sharing options...
Gruzin Posted March 30, 2007 Author Share Posted March 30, 2007 Full-Demon, Thanks a lot mate, but i've figured it out: Check to be sure you don't print any code begore the header() function call. If you print anything else to the browser page, PHP will generate a default content-type of text/html for you. This would cause the image to not be processed correctly, giving you the behavior you describe. If you want to display the graphic inline, you could save it as a file, then include it. Of course, you'd have to be creative if you're getting a lot of concurrent hits. (Maybe save image with a session ID then periodically destroy old images to save space) Link to comment https://forums.phpfreaks.com/topic/44893-gd-problem-with-linux/#findComment-218045 Share on other sites More sharing options...
Full-Demon Posted March 30, 2007 Share Posted March 30, 2007 Ok nice , I didnt saw any code before the header.... :S Full-Demon Link to comment https://forums.phpfreaks.com/topic/44893-gd-problem-with-linux/#findComment-218051 Share on other sites More sharing options...
Gruzin Posted March 30, 2007 Author Share Posted March 30, 2007 Can I save the GD image created into my directory (as a file)? Thanks, George Link to comment https://forums.phpfreaks.com/topic/44893-gd-problem-with-linux/#findComment-218290 Share on other sites More sharing options...
fert Posted March 30, 2007 Share Posted March 30, 2007 Can I save the GD image created into my directory (as a file)? Yes, you can Link to comment https://forums.phpfreaks.com/topic/44893-gd-problem-with-linux/#findComment-218292 Share on other sites More sharing options...
Gruzin Posted March 30, 2007 Author Share Posted March 30, 2007 Can I save the GD image created into my directory (as a file)? Yes, you can Well thanks fert, can u point me to right tutorial? Link to comment https://forums.phpfreaks.com/topic/44893-gd-problem-with-linux/#findComment-218293 Share on other sites More sharing options...
fert Posted March 30, 2007 Share Posted March 30, 2007 http://us2.php.net/manual/en/function.imagepng.php Link to comment https://forums.phpfreaks.com/topic/44893-gd-problem-with-linux/#findComment-218302 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.