9999 Posted October 30, 2007 Share Posted October 30, 2007 want to tke the output of php file and write image and save to server. <?php $file = file_get_contents('http://www.myfile.php'); $im = imagecreate(325, 160); $bg = imagecolorallocate($im, 0, 0, 0); $textcolor = imagecolorallocate($im, 255, 225, 255); imagestring($im, 5, 0, 0, $file, $textcolor); // write the string at the top left header("Content-type: image/gif"); // output the image imagegif($im,"new_image.gif",80); // save the image to server ?> Quote Link to comment https://forums.phpfreaks.com/topic/75309-any-errors-in-this-short-script/ Share on other sites More sharing options...
trq Posted October 30, 2007 Share Posted October 30, 2007 Does it work? Quote Link to comment https://forums.phpfreaks.com/topic/75309-any-errors-in-this-short-script/#findComment-380870 Share on other sites More sharing options...
9999 Posted October 30, 2007 Author Share Posted October 30, 2007 No, it does nothing. I was wondering if there are any syntax errors and iseverything used properly. Quote Link to comment https://forums.phpfreaks.com/topic/75309-any-errors-in-this-short-script/#findComment-380874 Share on other sites More sharing options...
trq Posted October 30, 2007 Share Posted October 30, 2007 Try putting.... <?php error_reporting(E_ALL); ini_set('display_errors','1'); ?> at the top of all your code while your developing. This helps in the debugging process. Quote Link to comment https://forums.phpfreaks.com/topic/75309-any-errors-in-this-short-script/#findComment-380878 Share on other sites More sharing options...
trq Posted October 30, 2007 Share Posted October 30, 2007 Actually (Ive just looked at your code), what exactly are you actually trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/75309-any-errors-in-this-short-script/#findComment-380881 Share on other sites More sharing options...
9999 Posted October 30, 2007 Author Share Posted October 30, 2007 I have a php file that when executed yields an output. I want to take that output and create an image out of it and save it to the server. Quote Link to comment https://forums.phpfreaks.com/topic/75309-any-errors-in-this-short-script/#findComment-380883 Share on other sites More sharing options...
trq Posted October 30, 2007 Share Posted October 30, 2007 Are you trying to thumbnail a site? Is the output you speak of html? If so, your image is simply going to be a picture of html code. Quote Link to comment https://forums.phpfreaks.com/topic/75309-any-errors-in-this-short-script/#findComment-380887 Share on other sites More sharing options...
9999 Posted October 30, 2007 Author Share Posted October 30, 2007 OK, here is what i have. This is what I want my php output to look like: http://www.dailyscripturecards.com/daily2.php when done. Instead of outputting it like the example above in which I used a table with a black background color, I want my php file above to just output the text. Then I will take the php script with the image create and use the outputted text from daily2.php and place that inside of the black box it creates then save the whole thing to the server. Quote Link to comment https://forums.phpfreaks.com/topic/75309-any-errors-in-this-short-script/#findComment-380894 Share on other sites More sharing options...
trq Posted October 30, 2007 Share Posted October 30, 2007 Not exaclty sure what your talking about there but this... <table style="background-color:black; overflow:hidden; width:325px; height:160px; padding:0px; border:0px"><tr><td><center><b><font face="Comic Sans MS" size="3.5px" color="White" >October 29</font></b></center><font face="Times New Roman" size="2px" color="White">Let not your heart be troubled: ye believe in God, believe also in me. In my Father's house are many mansions: if it were not so, I would have told you. I go to prepare a place for you. And if I go and prepare a place for you, I will come again, and receive you unto myself; that where I am, there ye may be also.</font><center><font face="Times New Roman" size="2.5px" color="White" >John 14: 1-3</font></center></td></tr></table> Is what will be retrieved by file_get_contents(). Quote Link to comment https://forums.phpfreaks.com/topic/75309-any-errors-in-this-short-script/#findComment-380895 Share on other sites More sharing options...
9999 Posted October 30, 2007 Author Share Posted October 30, 2007 OK lets try this php file: http://www.dailyscripturecards.com/daily.php I want to take the output of that file Let not your heart be troubled: ye believe in God, believe also in me. In my Father's house are many mansions: if it were not so, I would have told you. I go to prepare a place for you. And if I go and prepare a place for you, I will come again, and receive you unto myself; that where I am, there ye may be also. John 14: 1-3 (October 29) and create an image out of it and save it to the server. Does this help? Quote Link to comment https://forums.phpfreaks.com/topic/75309-any-errors-in-this-short-script/#findComment-380901 Share on other sites More sharing options...
trq Posted October 30, 2007 Share Posted October 30, 2007 Does this help? I'm not sure. This outputs.... <table style="width:310px; height:155px; padding:0px; border:0px;"><tr><td><font face="Times New Roman" size="2.5px">Let not your heart be troubled: ye believe in God, believe also in me. In my Father's house are many mansions: if it were not so, I would have told you. I go to prepare a place for you. And if I go and prepare a place for you, I will come again, and receive you unto myself; that where I am, there ye may be also.</font><center><font face="Times New Roman" size="3px">John 14: 1-3 (October 29)</font></center></td></tr></table> Either way, did you add the debug line I suggested? Does it throw any errors? Quote Link to comment https://forums.phpfreaks.com/topic/75309-any-errors-in-this-short-script/#findComment-380906 Share on other sites More sharing options...
9999 Posted October 30, 2007 Author Share Posted October 30, 2007 no, nothing is displayed when I run it Quote Link to comment https://forums.phpfreaks.com/topic/75309-any-errors-in-this-short-script/#findComment-380910 Share on other sites More sharing options...
trq Posted October 30, 2007 Share Posted October 30, 2007 It should display errors. For starters, imagegif() expects a maximum of 2 parameters, you've given it 3. Quote Link to comment https://forums.phpfreaks.com/topic/75309-any-errors-in-this-short-script/#findComment-380912 Share on other sites More sharing options...
9999 Posted October 30, 2007 Author Share Posted October 30, 2007 I guess you could say I am a newbie when it comes to php? How do I check for the errors and should I be using file_get_contents for what I'm trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/75309-any-errors-in-this-short-script/#findComment-380914 Share on other sites More sharing options...
trq Posted October 30, 2007 Share Posted October 30, 2007 ow do I check for the errors the line I posted earlier should be at the top of all scripts while developing. should I be using file_get_contents for what I'm trying to do? If you want the html source code in your image. If you don't wan't the html in there use strip_tags to remove it. Quote Link to comment https://forums.phpfreaks.com/topic/75309-any-errors-in-this-short-script/#findComment-380915 Share on other sites More sharing options...
9999 Posted October 30, 2007 Author Share Posted October 30, 2007 Maybe I should have explained everything differently. What I want to do is take the result of this php file: http://www.dailyscripturecards.com/daily.php which is literally this: Let not your heart be troubled: ye believe in God, believe also in me. In my Father's house are many mansions: if it were not so, I would have told you. I go to prepare a place for you. And if I go and prepare a place for you, I will come again, and receive you unto myself; that where I am, there ye may be also. John 14: 1-3 (October 29) Can you give me the code that would take that text output and put it in a box, thereby creating an image. Then that image needs to be saved on the server. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/75309-any-errors-in-this-short-script/#findComment-380919 Share on other sites More sharing options...
9999 Posted October 30, 2007 Author Share Posted October 30, 2007 Is imagecreate the best way to do this? Quote Link to comment https://forums.phpfreaks.com/topic/75309-any-errors-in-this-short-script/#findComment-381266 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.