Create a new GD image stream and outputting an image in PHP

Description

The following code shows how to create a new GD image stream and outputting an image.

Example


<?php/*from  w  w w .  ja  v a2 s  .  c  om*/
header ('Content-Type: image/png');
$im = @imagecreatetruecolor(120, 20)
      or die('Cannot Initialize new GD image stream');
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  'A Simple Text String', $text_color);
imagepng($im);
imagedestroy($im);
?>

The code above generates the following result.

Create a new GD image stream and outputting an image in PHP




















Home »
  PHP Tutorial »
    Image »




Color
Create
Font
Operation
Shape
Text