Skip to content
Related Articles

Related Articles

PHP | imageistruecolor() function
  • Last Updated : 31 Jan, 2020

The imageistruecolor() function is an inbuilt function in PHP which is used to find whether an image is a true-color image or not. A true-color image is an image in which each pixel is specified by three values, ie, RGB.

Syntax:

bool imageistruecolor( resource $image )

Parameters:This function accepts a single parameter $image which holds the image.

Return Value: This function returns TRUE if image is truecolor or FALSE in other case.

Below given programs illustrate the imageistruecolor() function in PHP:



Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// Create an image instance with a truecolor image
$im = imagecreatefrompng(
  
// Check if image is truecolor
$istruecolor = imageistruecolor($im);
  
// Show the output to browser
if($istruecolor) {
    echo "The image is true color";
}
?>

chevron_right


Output:

The image is true color

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// Create an image instance with a grayscale image
$im = imagecreatefrompng(
  
// Check if image is truecolor
$istruecolor = imageistruecolor($im);
  
// Show the output to browser
if(!$istruecolor) {
    echo "The image is not true color";
}
?>

chevron_right


Output:

The image is not true color

Reference: https://www.php.net/manual/en/function.imageistruecolor.php

My Personal Notes arrow_drop_up
Recommended Articles
Page :