To change the font style, you need to use different fonts. You can use the imagettftext() function to draw text on a php generated image using GD. Here’s a code snippet:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<?php header('Content-type: image/png'); $im = imagecreatetruecolor(400, 300); $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 128, 128, 128); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 399, 299, $white); $text = 'maSnun'; $font = '/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf'; imagettftext($im, 50,180, 300, 130, $black, $font, $text); imagepng($im); imagedestroy($im); ?> |
Have a look at the function’s doc on php.net to learn more. http://www.php.net/imagettftext 🙂
It’s not that hard! Put the file in the www directory of a ubuntu LAMP server and visit the url on a web browser 🙂