Find whether an image is a truecolor image in PHP
Description
The following code shows how to find whether an image is a truecolor image.
Example
<?php/*from ww w . j a v a 2 s. c o m*/
// Create an image instance
$im = imagecreatefromgif('php.gif');
// Check if image is a true color image or not
if(!imageistruecolor($im))
{
// Create a new true color image instance
$tc = imagecreatetruecolor(imagesx($im), imagesy($im));
// Copy over the pixels
imagecopy($tc, $im, 0, 0, 0, 0, imagesx($im), imagesy($im));
imagedestroy($im);
$im = $tc;
$tc = NULL;
// OR use imagepalettetotruecolor()
}
// Continue working with image instance
?>