Back to the snippets index

Create some text as an image ( Anthony 14/6/2008 )

This creates a background with a border and adds text to it.

GD code:

<?php
// Create the canvas
$canvas imagecreate15080 );

// First colour - this will be the default colour for the canvas
$light_blue imagecolorallocate$canvas176226255 );

// The second colour - to be used for the text
$black imagecolorallocate$canvas00);

// 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 canvas
imageTTFText$canvas$size01560$black$font$text );

// Save as Text.jpg
imagejpeg$canvas"Text.jpg" );

// Clear the memory of the tempory image 
ImageDestroy$canvas );
?>

Image to go with Create some text as an image example code
Change a png to a jpg
Create some text as an image
Crop an image
Display image without saving
Grayscale image
Resize an image
Rotate an image
Watermark an image