1. Home
  2. Computing & Technology
  3. PHP / MySQL

Imagestring () PHP Function

By , About.com Guide

Definition: Image String is used to add a string (text) to an image in PHP that we are creating with the GD Library.

It's parameters are:

  1. The image we are working with
  2. The font as a number, 1-5.
  3. Starting X ordinate
  4. Starting Y ordinate
  5. The string itself
  6. The color

<?php
header ("Content-type: image/png");
$handle = ImageCreate (130, 50) or die ("Cannot Create image");
$bg_color = ImageColorAllocate ($handle, 255, 0, 0);
$txt_color = ImageColorAllocate ($handle, 0, 0, 0);
ImageString ($handle, 5, 5, 18, "PHP.About.com", $txt_color);
ImagePng ($handle);
?>
Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. PHP Functions
  5. Image String - imagestring - GD Library Image String

©2009 About.com, a part of The New York Times Company.

All rights reserved.