imagecreatetruecolor() function in PHP


The imagecreatetruecolor() function creates a new true color image.

Syntax

imagecreatetruecolor (width , height )

Parameters

  • width: The image width.

  • height: The image height.

Return

The imagecreatetruecolor() function returns an image resource identifier on success, FALSE on errors.

Example

The following is an example

 Live Demo

<?php
   $img = imagecreatetruecolor(600, 500);
   echo imagesy($img);
   echo "<br>";
   echo imagesx($img);
?>

Output

The following is the output displaying the height and width of the new image:

500
600

Example

Let us see another example with different height and width:

 Live Demo

<?php
   $img = imagecreatetruecolor(300, 450);
   echo imagesy($img);
   echo "<br>";
   echo imagesx($img);
?>

Output

The following is the output displaying the height and width of the new image:

450
300

Updated on: 31-Dec-2019

646 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements