成人精品一区二区三区中文字幕-成人精品一区二区三区-成人精品一级毛片-成人精品亚洲-日本在线视频一区二区-日本在线视频免费

導航首頁 ? 技術教程 ? PHP:imagefttext()的用法_GD庫圖像處理函數
全站頭部文字 我要出現在這里
PHP:imagefttext()的用法_GD庫圖像處理函數 753 2023-12-15   

imagefttext

(PHP 4 >= 4.0.7, PHP 5)

imagefttext — 使用 FreeType 2 字體將文本寫入圖像

說明

array imagefttext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text [, array $extrainfo ] )

參數

image

由圖象創建函數(例如imagecreatetruecolor())返回的圖象資源。

size

The font size to use in points.

angle

The angle in degrees, with 0 degrees being left-to-right reading text. Higher values represent a counter-clockwise rotation. For example, a value of 90 would result in bottom-to-top reading text.

x

The coordinates given by x and y will define the basepoint of the first character (roughly the lower-left corner of the character). This is different from the imagestring(), where x and y define the upper-left corner of the first character. For example, "top left" is 0, 0.

y

The y-ordinate. This sets the position of the fonts baseline, not the very bottom of the character.

color

The index of the desired color for the text, see imagecolorexact().

fontfile

The path to the TrueType font you wish to use.

Depending on which version of the GD library PHP is using, when fontfile does not begin with a leading / then .ttf will be appended to the filename and the library will attempt to search for that filename along a library-defined font path.

When using versions of the GD library lower than 2.0.18, a space character, rather than a semicolon, was used as the 'path separator' for different font files. Unintentional use of this feature will result in the warning message: Warning: Could not find/open font. For these affected versions, the only solution is moving the font to a path which does not contain spaces.

In many cases where a font resides in the same directory as the script using it the following trick will alleviate any include problems.

<?php
// Set the enviroment variable for GD
putenv('GDFONTPATH=' . realpath('.'));

// Name the font to be used (note the lack of the .ttf extension)
$font = 'SomeFont';
?>

text

Text to be inserted into image.

extrainfo

Possible array indexes for extrainfo Key Type Meaning linespacing float Defines drawing linespacing

返回值

This function returns an array defining the four points of the box, starting in the lower left and moving counter-clockwise: 0 lower left x-coordinate 1 lower left y-coordinate 2 lower right x-coordinate 3 lower right y-coordinate 4 upper right x-coordinate 5 upper right y-coordinate 6 upper left x-coordinate 7 upper left y-coordinate

范例

Example #1 imagefttext() example

<?php
// Create a 300x100 image
$im = imagecreatetruecolor(300, 100);
$red = imagecolorallocate($im, 0xFF, 0x00, 0x00);
$black = imagecolorallocate($im, 0x00, 0x00, 0x00);

// Make the background red
imagefilledrectangle($im, 0, 0, 299, 99, $red);

// Path to our ttf font file
$font_file = './arial.ttf';

// Draw the text 'PHP Manual' using font size 13
imagefttext($im, 13, 0, 105, 55, $black, $font_file, 'PHP Manual');

// Output image to the browser
header('Content-Type: image/png');

imagepng($im);
imagedestroy($im);
?>

注釋

Note: 此函數需要 GD 2.0.1 或更高版本(推薦 2.0.28 及更高版本)。

Note: 此函數僅在 PHP 編譯時加入 freetype 支持時有效(--with-freetype-dir=DIR )。

更新日志

版本 說明 4.3.5 extrainfo was made optional.


主站蜘蛛池模板: 蛮荒的童话 电影| 《密爱》| 电影一对一| 杨超越穿游泳服装| 搜狐网站官网| 库尔斯克会战电影| 爱来的刚好演员表| 不要再来伤害我简谱| 女同性舌吻摸下身| 生男生女清宫图| 十万个冷笑话第二季| 哈尔的移动城堡日语版在线播放| 全国精神病查询系统官网| 尹雪喜最好看的三部电影| 酱园弄 电影| 赵健的读书日记| 杨功个人资料介绍| 社会好全部歌词| 弯刀| 明天属于我们法剧免费观看| 王小凤| 密使2之江都谍影 2013 于震| 荆棘花| 温子仁电影| 国产伦理女村支书| 糟老头视频| 红岩下的追捕电视剧| 被抛弃的青春1982| 魔法少女加奈| 五下数学第二单元思维导图| 法尔| 重点监管的危险化工工艺| 邓伦是石家庄哪里的| 五月天丁香婷婷| 2024年暑假师德师风心得体会| 洞房视频| 敦煌夜谭在线观看| 时间空间和人第二部| 色在线亚洲| 张俪写真集照片| 经典常谈周易第二读书笔记|

!!!站長長期在線接!!!

網站、小程序:定制開發/二次開發/仿制開發等

各種疑難雜癥解決/定制接口/定制采集等

站長微信:lxwl520520

站長QQ:1737366103