array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'en', ), 'this' => array ( 0 => 'function.imagecreatetruecolor.php', 1 => 'imagecreatetruecolor', ), 'up' => array ( 0 => 'ref.image.php', 1 => 'GD and Image Functions', ), 'prev' => array ( 0 => 'function.imagecreatefromxpm.php', 1 => 'imagecreatefromxpm', ), 'next' => array ( 0 => 'function.imagecrop.php', 1 => 'imagecrop', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/image/functions/imagecreatetruecolor.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)
imagecreatetruecolor — Create a new true color image
imagecreatetruecolor() returns an image object representing a black image of the specified size.
width
Image width.
height
Image height.
Returns an image object on success, false
on errors.
Version | Description |
---|---|
8.0.0 | On success, this function returns a GDImage instance now; previously, a resource was returned. |
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: