TFD3 Posted July 15, 2007 Share Posted July 15, 2007 I have a URL that displays a background image and text overlay but I was wanting to know if its possible to combine the two and have it show as a image? Here is the image/text overlay site: http://beta.alabamaweather.org/radar/radarimages/fun2.php Thanks, Kenny Link to comment https://forums.phpfreaks.com/topic/60021-solved-text-to-image/ Share on other sites More sharing options...
infid3l Posted July 15, 2007 Share Posted July 15, 2007 I have a URL that displays a background image and text overlay but I was wanting to know if its possible to combine the two and have it show as a image? Here is the image/text overlay site: http://beta.alabamaweather.org/radar/radarimages/fun2.php Thanks, Kenny If you have GDlib installed, you can use: http://ca3.php.net/manual/en/function.imagettftext.php Link to comment https://forums.phpfreaks.com/topic/60021-solved-text-to-image/#findComment-298506 Share on other sites More sharing options...
TFD3 Posted July 15, 2007 Author Share Posted July 15, 2007 I have a URL that displays a background image and text overlay but I was wanting to know if its possible to combine the two and have it show as a image? Here is the image/text overlay site: http://beta.alabamaweather.org/radar/radarimages/fun2.php Thanks, Kenny If you have GDlib installed, you can use: http://ca3.php.net/manual/en/function.imagettftext.php Its installed but dont know how to use it really. Link to comment https://forums.phpfreaks.com/topic/60021-solved-text-to-image/#findComment-298512 Share on other sites More sharing options...
infid3l Posted July 15, 2007 Share Posted July 15, 2007 That's why I linked to the manual. But I'll be nice this time: <?php header("Content-Type: image/png"); $im = imagecreatefrompng("background.png"); $white = imagecolorallocate($im, 255, 255, 255); imagettftext($im, 12, 0, 10, 15, $white, "times.ttf", date()); imagepng($im); ?> Upload your font ("times.ttf") into the same directory as the script and "background.png". Link to comment https://forums.phpfreaks.com/topic/60021-solved-text-to-image/#findComment-298514 Share on other sites More sharing options...
TFD3 Posted July 15, 2007 Author Share Posted July 15, 2007 That's why I linked to the manual. But I'll be nice this time: <?php header("Content-Type: image/png"); $im = imagecreatefrompng("background.png"); $white = imagecolorallocate($im, 255, 255, 255); imagettftext($im, 12, 0, 10, 15, $white, "times.ttf", date()); imagepng($im); ?> Upload your font ("times.ttf") into the same directory as the script and "background.png". this is what I get... http://beta.alabamaweather.org/radar/radarimages/fun3.php Link to comment https://forums.phpfreaks.com/topic/60021-solved-text-to-image/#findComment-298516 Share on other sites More sharing options...
infid3l Posted July 15, 2007 Share Posted July 15, 2007 I see this in the headers: Content-Type: text/html Should be "image/png" I edited the code I posted earlier, try it again. Link to comment https://forums.phpfreaks.com/topic/60021-solved-text-to-image/#findComment-298518 Share on other sites More sharing options...
TFD3 Posted July 15, 2007 Author Share Posted July 15, 2007 I see this in the headers: Content-Type: text/html Should be "image/png" I edited the code I posted earlier, try it again. works...cept the text. Here is what I have: <?php header("Content-Type: image/png"); $txt = testing; $im = imagecreatefrompng("http://beta.alabamaweather.org/radar/radarimages/background.png"); $white = imagecolorallocate($im, 255, 255, 255); imagettftext($im, 12, 0, 10, 15, $white, "arial.ttf", date('$txt')); imagepng($im); ?> and it displays: when it should say testing Link to comment https://forums.phpfreaks.com/topic/60021-solved-text-to-image/#findComment-298522 Share on other sites More sharing options...
infid3l Posted July 15, 2007 Share Posted July 15, 2007 <?php header("Content-Type: image/png"); $txt = "testing"; $im = imagecreatefrompng("http://beta.alabamaweather.org/radar/radarimages/background.png"); $white = imagecolorallocate($im, 255, 255, 255); imagettftext($im, 12, 0, 10, 15, $white, "arial.ttf", $txt); imagepng($im); ?> I don't know why you chose to make "testing" a constant or why you put $txt in date(), but try the code above. Link to comment https://forums.phpfreaks.com/topic/60021-solved-text-to-image/#findComment-298525 Share on other sites More sharing options...
TFD3 Posted July 15, 2007 Author Share Posted July 15, 2007 <?php header("Content-Type: image/png"); $txt = "testing"; $im = imagecreatefrompng("http://beta.alabamaweather.org/radar/radarimages/background.png"); $white = imagecolorallocate($im, 255, 255, 255); imagettftext($im, 12, 0, 10, 15, $white, "arial.ttf", $txt); imagepng($im); ?> I don't know why you chose to make "testing" a constant or why you put $txt in date(), but try the code above. have no idea...but it now works...thank you!!!!!!!!!!! Link to comment https://forums.phpfreaks.com/topic/60021-solved-text-to-image/#findComment-298530 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.