jonaHill87 Posted February 7, 2008 Share Posted February 7, 2008 Hi all. I don't know much this function so I'll try to be as clear as I can. I'm trying to create an image from a png file with text from an url(using get) over top of the image. I found this example on the php.net but I just can't to get it to work, I just keep getting a blank screen. http://www.php.net/manual/en/ref.image.php. You need to scroll down a bit, it's example 1. I'm sending my text data from one page that looks like this: As you can see I'm getting my text from a database but that's not the problem. <?php $query = "SELECT ButtonText FROM ButtonMenu"; $result = mysql_query($query); while ($query_data = mysql_fetch_row($result)) { foreach ($query_data as $entry) { echo "<img src='page2.php?text=$entry' />"; } } ?> to another page that looks like this. It contains the example code and I have added comments to the code lines that I'm not familiar with. Thanks to any1 that can help. Btw, my button.png is in the same dir as my php files. <?php header("Content-type: image/png"); $string = $_GET['text']; $im = imagecreatefrompng("Button.png"); $black = imagecolorallocate($im, 0, 0, 0); //I don't need any color so can I remove this line? $px = (imagesx($im) - 7.5 * strlen($string)) / 2; // not sure what's going on in this line. imagestring($im, 3, $px, 9, $string, $black); //would i need to remove anything here? imagepng($im); imagedestroy($im); ?> Quote Link to comment Share on other sites More sharing options...
priti Posted February 7, 2008 Share Posted February 7, 2008 Hi, <?php header("Content-type: image/png"); $string = $_GET['text']; $im = imagecreatefrompng("Button.png");button.png $black = imagecolorallocate($im, 0, 0, 0); //I don't need any color so can I remove this line? YES YOU CAN REMOVE THIS LINE. $px = (imagesx($im) - 7.5 * strlen($string)) / 2; // not sure what's going on in this line. THIS CALCULATE WHERE TO SHOW YOUR STRING ON IMAGE ( X ) imagestring($im, 3, $px, 9, $string, $black); //would i need to remove anything here? NO YOU DON'T HAVE TO CHANGE ANYTHING HERE IS $BLACK IS NULL OR EMPTY IT WILL TAKE IT AS WHITE COLOR.ALL FIELDS ARE MANDATORY NO OPTIONAL SO YOU HAVE TO GIVE THESE NUMBER OF PARAMETER IN imagestring() function. imagepng($im); imagedestroy($im); ?> let us know if things are not solved. Quote Link to comment 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.