imagecolormatch 


gd apg

MAKES the colors of the palette version of an image more closely match the true color version.





$image2 must have the same size as $image1.

This function returns TRUE on success or FALSE on failure.



<?php

bool imagecolormatch 
GdImage $image1GdImage $image2 )


where,

$image1 The image resourse or object 
                                          
for TRUECOLOR image 

$image2 
The image resourse or object 
                                          
for PALETTE image 

?>

  $image1   


A truecolor image link resource or object.



  $image2   


A palette image link resource or object.



  1 EXERCISE   

<?php

echo 'PHP VERSION: ' PHP_VERSION '<br><br>';

// $lang = 'pt';
$lang 'en';

$img_tc "jpeg/JPEG 027 01.jpg";
// TRUECOLOR IMAGE
$img_pl "gif/GIF 023 01-a.gif";
// PALETTE IMAGE
$img_rs "gif/GIF 023 01-b.gif";
// PALETTE IMAGE

echo basename($img_tc); ?><br><br>
<img src="<?php echo $img_tc?>"
alt="<?php echo $img_tc?>
title="<?php echo $img_tc?>" width="400"><br><br>

<?php echo basename($img_pl); ?><br><br>
<img src="<?php echo $img_pl?>"
alt="<?php echo $img_pl?>
title="<?php echo $img_pl?>" width="400"><br><br><br>

<?php

$id_imgtc 
imagecreatefromjpeg($img_tc);

$id_imgpl imagecreatefromgif($img_pl);

$is_clrmatch imagecolormatch($id_imgtc$id_imgpl);

if(
$is_clrmatch)
{
imagegif($id_imgpl$img_rs);

echo 
basename($img_rs); ?><br><br>
<img src="<?php echo $img_rs?>"
alt="<?php echo $img_rs?>
title="<?php echo $img_rs?>" width="400">
<?php
}
else
{
$pt "A imagem não pôde ser convertida!<br>";
$en "The image could not be converted!<br>";
echo 
'<br><br>' . $$lang;

}
?> 

 RESULT   

JPEG 027 01.jpg

JPEG 027 01.jpg apr

GIF 023 01-a.gif

GIF 023 01-a.gif apr


GIF 023 01-b.gif

GIF 023 01-b.gif apr