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

ImageColorAllocate () PHP Function

By Angela Bradley, About.com

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

Explore PHP / MySQL

More from About.com

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. PHP Functions
  5. Create Image - ImageColorAllocate - Image Color Allocate

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

All rights reserved.