Science, Tech, Math › Computer Science Imagecreatetruecolor() PHP Function PHP Imagecreatetruecolor() Function Generates 24-Bit Color Images Share Flipboard Email Print Computer Science PHP Programming Tutorials MySQL Commands Perl Python Java Programming Javascript Programming Delphi Programming C & C++ Programming Ruby Programming Visual Basic View More By Angela Bradley Computer Science Expert B.A, History, Eastern Oregon University Angela Bradley is a web designer and programming expert with over 15 years of experience. An expert in iOS software design and development, she specializes in building technical hybrid platforms. our editorial process Angela Bradley Updated August 21, 2017 The imagecreatetruecolor() function is used in PHP to create a new true color image using the GD Library. True color uses a 24-bit color depth when displaying an RGB image. Its two parameters are the width and height of the image you are creating. Sample Code Using Imagecreatetruecolor() Function This code generates a PNG image that is 130 pixels wide by 50 pixels high. The imagecreatetruecolor() function specifies a shape that is 130 pixels wide by 50 pixels high. The text color is set using RGB values. The text that will print on the shape is "A Simple Text String," in size 1 (of 1-5) with an x ordinate of 5 and a y-ordinate of 5. Return Values When successful, this function returns an image identifier that represents a black image of the specified size. If not successful, it returns "False." Considerations The GD library must be enabled for this function to work properly; otherwise, the return value is False. It can be downloaded free from the internet if you don't already have it installed. Imagecreatetruecolor() vs. Imagecreate() Function Although the imagecreate() function still works in PHP, the PHP manual recommends the use of the newer imagecreatetruecolor() function, which creates images with many more colorsmakes color transparency possibleallows advanced image processes Cite this Article Format mla apa chicago Your Citation Bradley, Angela. "Imagecreatetruecolor() PHP Function." ThoughtCo, Jan. 29, 2020, thoughtco.com/imagecreatetruecolor-php-function-2694064. Bradley, Angela. (2020, January 29). Imagecreatetruecolor() PHP Function. Retrieved from https://www.thoughtco.com/imagecreatetruecolor-php-function-2694064 Bradley, Angela. "Imagecreatetruecolor() PHP Function." ThoughtCo. https://www.thoughtco.com/imagecreatetruecolor-php-function-2694064 (accessed January 24, 2021). copy citation