1. Computing & Technology

Discuss in my forum

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); 
 ?> 

©2012 About.com. All rights reserved.

A part of The New York Times Company.