PHP imagecolormatch - make a version of the color palette of the image and to better match the true color version
imagecolormatch - make a version of the color palette of the image and true color version better match.
grammar
bool imagecolormatch ( resource $image1 , resource $image2 )
Make a version of the image in color palette and true color version better match.
Note: This function is only available with bundled GD library compiled PHP version.
Note: This function requires GD 2.0.1 or later (2.0.28 or later recommended).
parameter
- image1 true color image connection resources.
- image2 must be Palette image, and the size of image1 and must be the same.
return value
Successful return TRUE, or on failure returns FALSE.
Examples
<?php // 创建真彩色图像和调色板图像 $im1 = imagecreatefrompng('w3big-logo.png'); $im2 = imagecreate(imagesx($im1), imagesy($im1)); // 向 $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); // 把这些颜色与真彩色图像进行匹配 imagecolormatch($im1, $im2); // 从内存中释放 imagedestroy($im1); imagedestroy($im2); ?>
related articles
- imagecreatetruecolor () Create a new true color image.