Create a new true color image

imagecreatefromxpm
imagecrop
GD and Image Functions
PHP Manual

# imagecreatetruecolor

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

imagecreatetruecolor — Create a new true color image

### Description

resource imagecreatetruecolor ( int `$width` , int `$height` )

imagecreatetruecolor() returns an image identifier representing a black image of the specified size.

Depending on your PHP and GD versions this function is defined or not. With PHP 4.0.6 through 4.1.x this function always exists if the GD module is loaded, but calling it without GD2 being installed PHP will issue a fatal error and exit. With PHP 4.2.x this behaviour is different in issuing a warning instead of an error. Other versions only define this function, if the correct GD version is installed.

### Parameters

`width`

  Image width.

`height`

  Image height.

### Return Values

Returns an image resource identifier on success, `FALSE` on errors.

### Examples

Example #1 Creating a new GD image stream and outputting an image.

`<?php
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 above example will output something similar to:

### Notes

> Note: This function requires GD 2.0.1 or later (2.0.28 or later is recommended).

### See Also

- imagedestroy() - Destroy an image
- imagecreate() - Create a new palette based image

imagecreatefromxpm
imagecrop
GD and Image Functions
PHP Manual