1. Computing & Technology

Discuss in my forum

ImageColorAllocate () PHP Function

By , About.com Guide

Definition: The ImageColorAllocate () function is used in PHP to set the color for an image you are creating with the GD Library. It's parameters are:

  1. The image
  2. Red Value
  3. Green Value
  4. Blue Value

The color values range from 0 to 255. If you are unfamiliar with choosing colors in this way this is a useful site that can help.

Also Known As: Image Create True Color, PHP Image Create True Color
Examples:
<?php 
 header ("Content-type: image/png"); 
 $handle = ImageCreate (130, 50) or die ("Cannot Create image"); 
 $bg_color = ImageColorAllocate ($handle, 255, 111, 0); 
 ImagePng ($handle); 
 ?>

©2012 About.com. All rights reserved.

A part of The New York Times Company.