Snippets - GD
Create some text as an image - Anthony 14/6/2008
This creats a background with a border and adds text to it.
<?php// Create the canvas$canvas = imagecreate( 150, 80 );// First colour - this will be the default colour for the canvas$light_blue = imagecolorallocate( $canvas, 176, 226, 255 );// The second colour - to be used for the text$black = imagecolorallocate( $canvas, 0, 0, 0 );// Path to the font you are going to use$font = "verdana.ttf";// Text to write$text = "Text";// Font size$size = "40";// Add the text to the canvasimageTTFText( $canvas, $size, 0, 15, 60, $black, $font, $text );// Save as Text.jpgimagejpeg( $canvas, "Text.jpg" );// Clear the memory of the tempory imageImageDestroy( $canvas );?>
