Draw string and fill rectangle in PHP

Description

The following code shows how to draw string and fill rectangle.

Example


<?php//from  ww w.  j  a  v a  2s .c om
  header("Content-type: image/gif");
  $imgcord = imagecreate(500,500);
  
  $blue = imagecolorallocate($imgcord, 0,0,255);
  $red = imagecolorallocate($imgcord, 255,0,0);

  ImageRectangle($imgcord, 175,165, 200,225, $blue);
  ImageFill($imgcord, 0,0, $red);
  ImageString($imgcord, 3,170, 220,"www.java2s.com", $blue);
  ImagePNG($imgcord);
  ImageDestroy($imgcord);
?>

The code above generates the following result.

Draw string and fill rectangle in PHP




















Home »
  PHP Tutorial »
    Image »




Color
Create
Font
Operation
Shape
Text