Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<imagecreatefromxpmimagecrop>
^GD and Image FunctionsLast updated: Mon, 26 Oct 2026

imagecreatetruecolor

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

imagecreatetruecolor — Create a new true color image

Description

function imagecreatetruecolor(int $width, int $height): GdImage|false

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

Parameters

width

Image width.

height

Image height.

Return Values

Returns an image object on success, false on errors.

Changelog

Version Description
8.0.0 On success, this function returns a GDImage instance now; previously, a resource was returned.

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

The above example will output something similar to:

Output of example : Creating a new GD image stream and outputting an image.

See Also


<imagecreatefromxpmimagecrop>
^GD and Image FunctionsLast updated: Mon, 26 Oct 2026