Imagick::mapImage()函数是PHP中的内置函数,用于用与参考图像最接近的颜色替换图像的颜色。
用法:
bool Imagick::mapImage( Imagick $map, float $dither )
参数:该函数接受上述和以下描述的两个参数:
- $map:此参数保存Imagick对象。
 - $dither:此参数包含一个布尔值,该布尔值决定是否添加噪声。
 
返回值:成功时此函数返回TRUE。
错误/异常:此函数在错误时引发ImagickException。
以下示例程序旨在说明PHP中的Imagick::mapImage()函数:
示例1:
<?php 
  
// Create a new imagick object 
$imagick1 = new Imagick( 
'https://media.geeksforgeeks.org/wp-content/uploads/20190823154611/geeksforgeeks24.png'); 
   
// Create another imagick object 
$imagick2 = new Imagick( 
'https://media.geeksforgeeks.org/wp-content/uploads/20190901195451/mattefloodfillimage.png'); 
   
// Mapping the image with noise 
$imagick1->mapImage($imagick2, true); 
   
header("Content-Type: image/jpg");  
     
// Display the output image  
echo $imagick1->getImageBlob(); 
  
?>输出:

示例2:
<?php 
  
// Create a new imagick object 
$imagick1 = new Imagick( 
'https://media.geeksforgeeks.org/wp-content/uploads/20190823154611/geeksforgeeks24.png'); 
   
// Create another imagick object 
$imagick2 = new Imagick( 
'https://media.geeksforgeeks.org/wp-content/uploads/20190901195451/mattefloodfillimage.png'); 
   
// Mapping the image without noise 
$imagick1->mapImage($imagick2, false); 
   
header("Content-Type: image/jpg");  
     
// Display the output image  
echo $imagick1->getImageBlob(); 
  
?>输出:

参考: https://www.php.net/manual/en/imagick.mapimage.php
相关用法
- PHP Imagick getImageCompose()用法及代码示例
 - PHP Imagick getImageChannelStatistics()用法及代码示例
 - PHP Imagick getImageClipMask()用法及代码示例
 - PHP Imagick getImageChannelMean()用法及代码示例
 - PHP Imagick getImageChannelExtrema()用法及代码示例
 - PHP Imagick setImageClipMask()用法及代码示例
 - PHP Imagick setImageBorderColor()用法及代码示例
 - PHP Imagick haldClutImage()用法及代码示例
 - PHP Imagick getImageBackgroundColor()用法及代码示例
 - PHP Imagick getImageChannelDistortion()用法及代码示例
 - PHP Imagick setImageBluePrimary()用法及代码示例
 - PHP Imagick getImageBorderColor()用法及代码示例
 - PHP Imagick setImageBackgroundColor()用法及代码示例
 - PHP Imagick readImageBlob()用法及代码示例
 - PHP Imagick setImageCompose()用法及代码示例
 
注:本文由纯净天空筛选整理自gurrrung大神的英文原创作品 PHP | Imagick mapImage() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
