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

導(dǎo)航首頁 ? 技術(shù)教程 ? PHP:imageftbbox()的用法_GD庫圖像處理函數(shù)
全站頭部文字 我要出現(xiàn)在這里
PHP:imageftbbox()的用法_GD庫圖像處理函數(shù) 781 2023-12-15   

imageftbbox

(PHP 4 >= 4.0.7, PHP 5)

imageftbbox — 給出一個(gè)使用 FreeType 2 字體的文本框

說明

array imageftbbox ( float $size , float $angle , string $fontfile , string $text [, array $extrainfo ] )

This function calculates and returns the bounding box in pixels for a FreeType text.

參數(shù)

size

字體的尺寸。根據(jù) GD 的版本,為像素尺寸(GD1)或點(diǎn)(磅)尺寸(GD2)。

angle

Angle in degrees in which text will be measured.

fontfile

The name of the TrueType font file (can be a URL). Depending on which version of the GD library that PHP is using, it may attempt to search for files that do not begin with a leading '/' by appending '.ttf' to the filename and searching along a library-defined font path.

text

The string to be measured.

extrainfo

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

返回值

imageftbbox() returns an array with 8 elements representing four points making the bounding box of the text: 0 lower left corner, X position 1 lower left corner, Y position 2 lower right corner, X position 3 lower right corner, Y position 4 upper right corner, X position 5 upper right corner, Y position 6 upper left corner, X position 7 upper left corner, Y position

The points are relative to the text regardless of the angle, so "upper left" means in the top left-hand corner seeing the text horizontally.

范例

Example #1 imageftbbox() example

<?php
// Create a 300x150 image
$im = imagecreatetruecolor(300, 150);
$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);

// Set the background to be white
imagefilledrectangle($im, 0, 0, 299, 299, $white);

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

// First we create our bounding box
$bbox = imageftbbox(10, 0, $font, 'The PHP Documentation Group');

// This is our cordinates for X and Y
$x = $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2) - 5;
$y = $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2) - 5;

imagefttext($im, 10, 0, $x, $y, $black, $font, 'The PHP Documentation Group');

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

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

注釋

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

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

更新日志

版本 說明 4.3.5 extrainfo was made optional.


主站蜘蛛池模板: 痛风能吃的菜一览表| 男人不可以穷演员表| 在线黄色片| 好看的拉片| 雅雅英| 炊事班的故事演员表| 日韩女优在线| 除暴电影| 6套电影频道节目表| 东星斑鱼图片| 抓特务| 第一财经直播电视直播今日股市| 小虎队《爱》歌词| 黑帮大佬365日| 《七律长征》的简笔画| 电影《kiskisan》在线播放 | 远景山谷1981美国电影在线观看| 你是我的玫瑰花简谱| 自拍在线| 女用春情药什么好| 我家来了个怪男人| 姐妹微电影| 陈思敏1一5集国语版在线播放| 摘抄现代诗| 沉默的较量| 拾贝的小女孩阅读理解答案 | 清淮河| 金太狼的幸福生活演员表_| 托洛斯基| 浙江卫视台节目表| 啼笑姻缘| elles club| 爱来的刚好演员表| 日本电影芋虫| 一年级下册语文期末测试卷可打印| 绝望的主妇第八季| 向团组织靠拢的打算| 火辣监狱在线观看| 红海行动演员表| 散文诗二首批注| 贵阳三中|

!!!站長(zhǎng)長(zhǎng)期在線接!!!

網(wǎng)站、小程序:定制開發(fā)/二次開發(fā)/仿制開發(fā)等

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

站長(zhǎng)微信:lxwl520520

站長(zhǎng)QQ:1737366103