ImagickDraw::comment()函數是PHP中的內置函數,用於向向量輸出流添加注釋。注釋將附加在輸出流的末尾。
用法:
bool ImagickDraw::comment( string $comment )
參數:該函數接受一個包含注釋的單個參數$comment。
返回值:成功時此函數返回TRUE。
異常:該函數在錯誤時引發ImagickException。
下麵給出的程序說明了PHP中的ImagickDraw::comment()函數:
程序1:
<?php
//Create a new Imagick object
$imagick = new Imagick();
// Create a image on imagick object
$imagick->newImage(800, 250, 'white');
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Add comment
$draw->comment('Hello ! This is my comment.');
// Get the vector graphics as string
$graphics = $draw->getVectorGraphics();
// Get comment from vector graphics
$comment = substr($graphics, 807);
echo $comment;
?>
輸出:
Hello ! This is my comment.
程序2:
<?php
//Create a new Imagick object
$imagick = new Imagick();
// Create a image on imagick object
$imagick->newImage(800, 250, 'white');
// Create a new ImagickDraw object
$draw = new ImagickDraw();
$string = 'This is my comment';
// Add comment
$draw->comment($string);
// Get the vector graphics
$graphics = $draw->getVectorGraphics();
// Get comment from vector graphics
$getComment = substr($graphics, 807, strlen($string));
// Set the font size
$draw->setFontSize(50);
// Write on image
$draw->annotation(50, 100, $getComment);
// Render the draw commands
$imagick->drawImage($draw);
// Show the output
$imagick->setImageFormat('png');
header("Content-Type:image/png");
echo $imagick->getImageBlob();
?>
輸出:
參考: https://www.php.net/manual/en/imagickdraw.comment.php
相關用法
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw getStrokeWidth()用法及代碼示例
- PHP ImagickDraw pathCurveToSmoothAbsolute()用法及代碼示例
- PHP ImagickDraw pathEllipticArcAbsolute()用法及代碼示例
- PHP ImagickDraw pathCurveToRelative()用法及代碼示例
- PHP ImagickDraw setTextKerning()用法及代碼示例
- PHP ImagickDraw clone()用法及代碼示例
- PHP ImagickDraw getFont()用法及代碼示例
- PHP ImagickDraw pathCurveToQuadraticBezierSmoothRelative()用法及代碼示例
- PHP ImagickDraw getStrokeDashArray()用法及代碼示例
- PHP ImagickDraw getTextAntialias()用法及代碼示例
- PHP ImagickDraw setStrokeLineCap()用法及代碼示例
- PHP ImagickDraw getStrokeLineCap()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | ImagickDraw comment() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。