PHP GD add text to image


 

PHP GD add text to image

In this example we know how to add text to image in php gd.

In this example we know how to add text to image in php gd.

PHP GD  Add text to Images

<?php

$im = imagecreatetruecolor(300, 300);

$w = imagesx($im);

$h = imagesy($im);

$text = imagecreatetruecolor($w, $h);

imagestring($text, 50, 50, 50, 'Hello', 0x0000FF);

imagecopymerge($im, $text, 50, 50, 50, 50, $w, $h, 1000);

header('Content-Type: image/gif');

imagegif($im);

imagedestroy ($text);

imagedestroy($im);

?>

After running the program you will get the following output

Ads