inferium Posted January 5, 2009 Share Posted January 5, 2009 I've made a script based on a tutorial, and I have the basice function working. It's just a basic script to put text over an image from my server. My question is this: how can I put multiple strings of text positioned across the image? <?php $image = ImageCreateFromPNG("image.png"); $color = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); $colorShadow = imagecolorallocate($image, 0x66, 0x66, 0x66); $font = 'arial.ttf'; $fontSize = "12"; $fontRotation = "0"; $str = "Example of GD in PHP. Date: " . date("m-j-Y g:i:s (a)"); /* Shadow */ ImageTTFText($image, $fontSize, $fontRotation, 7, 22, $colorShadow, $font, $str); /* Top Level */ ImageTTFText($image, $fontSize, $fontRotation, 5, 20, $color, $font, $str); header("Content-Type: image/PNG"); ImagePng ($image); imagedestroy($image); ?> Quote Link to comment https://forums.phpfreaks.com/topic/139568-solved-how-to-create-multiple-text-boxes-on-image/ Share on other sites More sharing options...
Maq Posted January 5, 2009 Share Posted January 5, 2009 Sorry I'm not familiar with the API that you're using. Maybe you could put the images as a background? Quote Link to comment https://forums.phpfreaks.com/topic/139568-solved-how-to-create-multiple-text-boxes-on-image/#findComment-730153 Share on other sites More sharing options...
flyhoney Posted January 5, 2009 Share Posted January 5, 2009 Just call the function multiple times, but change the position: <?php $image = ImageCreateFromPNG("image.png"); $color = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); $colorShadow = imagecolorallocate($image, 0x66, 0x66, 0x66); $font = 'arial.ttf'; $fontSize = "12"; $fontRotation = "0"; $str = "Example of GD in PHP. Date: " . date("m-j-Y g:i:s (a)"); /* Shadow */ ImageTTFText($image, $fontSize, $fontRotation, 7, 22, $colorShadow, $font, $str); /* Top Level */ ImageTTFText($image, $fontSize, $fontRotation, 5, 20, $color, $font, $str); $str = "Some more text"; /* Shadow */ ImageTTFText($image, $fontSize, $fontRotation, 7, 52, $colorShadow, $font, $str); /* Top Level */ ImageTTFText($image, $fontSize, $fontRotation, 5, 50, $color, $font, $str); header("Content-Type: image/PNG"); ImagePng ($image); imagedestroy($image); ?> Quote Link to comment https://forums.phpfreaks.com/topic/139568-solved-how-to-create-multiple-text-boxes-on-image/#findComment-730157 Share on other sites More sharing options...
flyhoney Posted January 5, 2009 Share Posted January 5, 2009 Sorry I'm not familiar with the API that you're using. Maybe you could put the images as a background? GD library (http://us3.php.net/imagettftext) Quote Link to comment https://forums.phpfreaks.com/topic/139568-solved-how-to-create-multiple-text-boxes-on-image/#findComment-730160 Share on other sites More sharing options...
inferium Posted January 5, 2009 Author Share Posted January 5, 2009 Ah sweet, this is just what I needed. Thanks a bunch!!! Quote Link to comment https://forums.phpfreaks.com/topic/139568-solved-how-to-create-multiple-text-boxes-on-image/#findComment-730173 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.