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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。