Gmagick::annotateImage()函數是PHP中的內置函數,用於用文本注釋圖像。成功時此函數返回True。
用法:
Gmagick Gmagick::annotateimage( $GmagickDraw, $x, $y, $angle, $text )
參數:該函數接受上述和以下所述的五個參數:
- $GmagickDraw:此參數用於創建GmagickDraw對象,該對象包含用於繪製文本的設置。
- $x:此參數設置為文本左側的水平偏移量(以像素為單位)。
- $y:此參數設置為相對於文本基線的垂直偏移(以像素為單位)。
- $angle:書寫文字的角度。
- $text:需要繪製的字符串。
返回值:該函數返回帶有注釋的Gmagick對象。
以下示例程序旨在說明PHP中的Gmagick::annotateImage()函數:
示例1:
<?php
/* Create some objects */
$image = new Gmagick();
$draw = new GmagickDraw();
$pixel = new GmagickPixel('white');
/* New image */
$image->newImage(800, 300, $pixel);
/* Black text */
$draw->setFillColor('green');
/* Font properties */
$draw->setFont('Bookman-DemiItalic');
$draw->setFontSize( 30 );
/* Create text */
$image->annotateImage($draw, 30, 140, 0,
'GeeksforGeeks: A computer science portal');
/* Give image a format */
$image->setImageFormat('png');
/* Output the image with headers */
header('Content-type: image/png');
echo $image;
?>
輸出:
示例2:
<?php
/* Create some objects */
$image = new Gmagick();
$draw = new GmagickDraw();
$image = new Gmagick(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-9.png');
/* Black text */
$draw->setFillColor('green');
/* Font properties */
$draw->setFont('Bookman-DemiItalic');
$draw->setFontSize( 30 );
/* Create text */
$image->annotateImage($draw, 5, 120, 0,
'GeeksforGeeks: A computer science portal');
/* Give image a format */
$image->setImageFormat('png');
/* Output the image with headers */
header('Content-type: image/png');
echo $image;
?>
輸出:
參考: http://php.net/manual/en/gmagick.annotateimage.php
相關用法
- PHP Imagick annotateImage()用法及代碼示例
- PHP Gmagick borderImage()用法及代碼示例
- PHP Gmagick medianfilterimage()用法及代碼示例
- PHP Gmagick getImageDispose()用法及代碼示例
- PHP Gmagick embossimage()用法及代碼示例
- PHP Gmagick commentImage()用法及代碼示例
- PHP Gmagick blurimage()用法及代碼示例
- PHP Gmagick setimagecolorspace()用法及代碼示例
- PHP Gmagick getImageMatte()用法及代碼示例
- PHP Gmagick write()用法及代碼示例
- PHP Gmagick getimageformat()用法及代碼示例
- PHP Gmagick setImageDispose()用法及代碼示例
- PHP Gmagick implodeimage()用法及代碼示例
- PHP Gmagick flipimage()用法及代碼示例
- PHP Gmagick labelimage()用法及代碼示例
注:本文由純淨天空篩選整理自R_Raj大神的英文原創作品 PHP | Gmagick annotateImage() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。