stuffradio Posted June 23, 2009 Share Posted June 23, 2009 Ok, so I have a php file that creates the image. In that file, I have it calling a script that is supposed to write text on the image, but that script that is supposed to write text on the image doesn't work. This is what gets outputted in the browser: http://localhost/wp-2.7/wp-content/plugins/captionbuilder/imagedisplay.php?text=testtt&file=winabout.jpg Here is the code: <?php $imag = $_GET['file']; $path = $_SERVER['DOCUMENT_ROOT']."wp-2.7/wp-content/uploads/" . $imag; $im = imagecreatefromjpeg($path); $cor = imagecolorallocate($im, 0, 0, 0); $white = imagecolorallocate($im, 255, 255, 255); $text = $_GET['text']; header ('Content-type: image/jpeg'); imagettftext($im, 18, 0, 10, 5, $cor, 'Arial', $text); imagejpeg($im); ?> Any idea what I'm doing wrong? I want to have text on the top of the image and on the bottom. I just need to know how to do this correctly though and I will figure out the positioning part. Quote Link to comment https://forums.phpfreaks.com/topic/163320-text-on-image/ Share on other sites More sharing options...
RussellReal Posted June 23, 2009 Share Posted June 23, 2009 the font parameter needs to be a .ttf file or relative path to it.. you can't specify 'Arial' Quote Link to comment https://forums.phpfreaks.com/topic/163320-text-on-image/#findComment-861704 Share on other sites More sharing options...
stuffradio Posted June 23, 2009 Author Share Posted June 23, 2009 Thanks for the reply, but it still doesn't work: <?php header ('Content-type: image/jpeg'); $imag = $_GET['file']; $path = $_SERVER['DOCUMENT_ROOT']."wp-2.7/wp-content/uploads/" . $imag; $im = imagecreatefromjpeg($path); $cor = imagecolorallocate($im, 0, 0, 0); $white = imagecolorallocate($im, 255, 255, 255); $text = $_GET['text']; $font = 'arial.ttf'; imagettftext($im, 18, 0, 10, 5, $cor, $font, $text); imagejpeg($im); ?> Quote Link to comment https://forums.phpfreaks.com/topic/163320-text-on-image/#findComment-861705 Share on other sites More sharing options...
GingerRobot Posted June 23, 2009 Share Posted June 23, 2009 Is arial.ttf in the folder that this file is? Quote Link to comment https://forums.phpfreaks.com/topic/163320-text-on-image/#findComment-861712 Share on other sites More sharing options...
stuffradio Posted June 23, 2009 Author Share Posted June 23, 2009 No it isn't. Edit: Ohhh thanks, it works now Quote Link to comment https://forums.phpfreaks.com/topic/163320-text-on-image/#findComment-861730 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.