imageistruecolor 


gd apg

FINDS whether an image is a truecolor image or not.





This function get the index of an specific pixel color $image.





$image symbolized by a identifier returned by one of the image creation functions, such as imagecreate or imagecreatetruecolor.


This function returns TRUE if $image is TRUECOLOR or FALSE if not.



<?php

bool imageistruecolor
( GdImage $image )


where,

$image = The image identifier 

?>
 

  $image   


The image identifier.



  1 EXERCISE   

<?php

function istruecolor ($tstimg)
{
    if(
imageistruecolor($tstimg))
    {
        echo 
'<br>The image file 
             tested IS TRUECOLOR!<br><br>'
;
    }
    else
    {
        echo 
'<br>The image file 
             tested IS NOT TRUECOLOR!<br><br><br>'
;
    }
}

$tst_img01a = "gif/GIF 010 02.gif"; 

$tst_img01b = "png/PNG 020 01 (gd22png).png"; 

echo 
$tst_img01a; ?><br>Existing Image 
<br><br><img src="<?php echo $tst_img01a; ?>" 
alt="<?php echo $tst_img01a; ?>"><br><br> 

<?php 

$id_01a 
= imagecreatefromgif($tst_img01a); 
$nbcolors01a = imagecolorstotal($id_01a); 
echo 
'Number total of colors<br>
in this image: ' 
. $nbcolors01a . '<br>'; 

istruecolor($id_01a);

echo 
$tst_img01b; ?><br>Existing Image
<br><br><img src="<?php echo $tst_img01b; ?>" 
alt="<?php echo $tst_img01b; ?>"><br><br> 

<?php 

$id_01b 
= imagecreatefrompng($tst_img01b); 
$nbcolors01b = imagecolorstotal($id_01b); 
echo 
'Number total of colors<br>
in this image: ' 
. $nbcolors01b . '<br>';
 
istruecolor($id_01b);

?> 

 RESULT   

GIF 010 02.gif

GIF 010 02.gif apr

Number total of colors
in this image: 256.

The image file tested IS NOT TRUECOLOR!




PNG 020 01 (gd22png).png

PNG 020 01 (gd22png).png apr

Number total of colors
in this image: 0, (ZERO).

The image file tested IS TRUECOLOR!