Create a gif image with draw a string in PHP

Description

The following code shows how to create a gif image with draw a string.

Example


<?php/*  w w w .  j  av a  2  s  . c o  m*/
    $animage = imagecreate (200, 200);
    $red = imagecolorallocate ($animage, 255, 0, 0);
    imagerectangle ($animage, 0, 0, 200, 200, $red);
    $white = imagecolorallocate ($animage, 255, 255, 255);
    imagestring($animage, 5, 45, 50, "Hello World!", $white);
    imagegif ($animage);
    header ("Content-type: image/gif");
    imagedestroy ($animage);
?>

The code above generates the following result.

Create a gif image with draw a string in PHP




















Home »
  PHP Tutorial »
    Image »




Color
Create
Font
Operation
Shape
Text