array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.imagecolormatch.php', 1 => 'imagecolormatch', ), 'up' => array ( 0 => 'ref.image.php', 1 => 'GD 和图像处理 函数', ), 'prev' => array ( 0 => 'function.imagecolorexactalpha.php', 1 => 'imagecolorexactalpha', ), 'next' => array ( 0 => 'function.imagecolorresolve.php', 1 => 'imagecolorresolve', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/image/functions/imagecolormatch.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)
imagecolormatch — 使一个图像中调色板版本的颜色与真彩色版本更能匹配
image1
真彩色图像对象。
image2
调色板图像对象,指向与 image1
相同大小的图像。
示例 #1 imagecolormatch() 示例
<?php
// Setup the true color and palette images
$im1 = imagecreatefrompng('./gdlogo.png');
$im2 = imagecreate(imagesx($im1), imagesy($im1));
// Add some colors to $im2
$colors = Array();
$colors[] = imagecolorallocate($im2, 255, 36, 74);
$colors[] = imagecolorallocate($im2, 40, 0, 240);
$colors[] = imagecolorallocate($im2, 82, 100, 255);
$colors[] = imagecolorallocate($im2, 84, 63, 44);
// Match these colors with the true color image
imagecolormatch($im1, $im2);
// Free from memory
imagedestroy($im1);
imagedestroy($im2);
?>