The PHP Function ImagecreateTrueColor
Image creation is one of the main areas of PHP and its GD library. The library is a set of functions that allow dynamic image creation and editing of various file types, such as GIF, JPEG and PNG. The GD library will be included with most shared hosting providers and should also be installed on your server if you are running a dedicated host.
Imagecreatetruecolor is used to create a new true color image. It takes a two paramters, the width and height of the image to be created. It returns an image resource identifier on success and FALSE on errors.
It is recommended to use this function instead of imagecreate or imagecreatefromjpeg if you are trying to save a true color image to a PNG or GIF format. This will make sure that you are saving a true color image and not a paletted version. This will help prevent any pixelation or artifacts from occurring.
For example, the
For example, if you are using a TGA with a 256 color palette and try to convert it to a GIF, you will get the error 'gif cannot be converted from a 256 color palette.' This is because GD expects that the image is a true color image and will not work with a 256 color paletted image.