📜  PHP | imagick的commentImage()函数

📅  最后修改于: 2022-05-13 01:56:24.419000             🧑  作者: Mango

PHP | imagick的commentImage()函数

Imagick::commentImage()函数是PHP中的一个内置函数,用于在图像中添加注释。

句法:

bool Imagick::commentImage( $comment )

参数:此函数接受一个用于保存注释的参数$ comment。

返回值:此函数在成功时返回 True。

原图:

下面的程序说明了PHP中的Imagick::commentImage()函数:
方案一:

commentImage("GeeksforGeeks");
  
// Display the comment 
echo $image->getImageProperty("comment");
  
?>

输出:

GeeksforGeeks

方案二:
由 Imagick函数创建的图像:

setFillColor(new ImagickPixel('green'));
  
// Set the text font size
$draw->setFontSize(50);
  
$metrix = $im->queryFontMetrics($draw, $string);
$draw->annotation(0, 40, $string);
$im->newImage($metrix['textWidth'], $metrix['textHeight'],
         new ImagickPixel('white'));
           
// Draw the image         
$im->drawImage($draw);
  
// Function to add border image
$im->borderImage(new ImagickPixel('Blue'), 5, 5);
  
// Function to add comment
$im->commentImage("G4G");
  
// Function to set the image format
$im->setImageFormat('png');
   
// Printing Added Comment 
echo $im->getImageProperty("comment");
?>

输出:

G4G

参考: http: PHP。 PHP