PHP:imageftbbox

moe*_*oey 3 php gd image

PHP imageftbbox中文本边界框的应用是什么?

在本手册的示例中,它用于确定imagefttext函数的坐标.有必要吗?也许我在这里遗漏了一些东西.

...

// 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');

...
Run Code Online (Sandbox Code Playgroud)

ari*_*ayu 5

Flylib有关于imagettfbox()的广泛信息.

以下是链接信息中的一些相关信息:

在此输入图像描述

(图片版权所有Flylib)

从上图中,您可以看到有4个点有8个信息(如文档中所述):

Array information     Bounding box coordinate
===================================================================
    0                 X coordinate of the lower left hand corner
    1                 Y coordinate of the lower left hand corner
    2                 X coordinate of the lower right hand corner
    3                 Y coordinate of the lower right hand corner
    4                 X coordinate of the upper right hand corner
    5                 Y coordinate of the upper right hand corner
    6                 X coordinate of the upper left hand corner
    7                 Y coordinate of the upper left hand corner
Run Code Online (Sandbox Code Playgroud)

同样,如文档所述,无论角度如何,此信息都与文本相关.因此,如果将文本顺时针旋转90度,则边界框将变为:

Array information     Bounding box coordinate
===================================================================
    0                 X coordinate of the upper left hand corner
    1                 Y coordinate of the upper left hand corner
    2                 X coordinate of the lower left hand corner
    3                 Y coordinate of the lower left hand corner
    4                 X coordinate of the lower right hand corner
    5                 Y coordinate of the lower right hand corner
    6                 X coordinate of the upper right hand corner
    7                 Y coordinate of the upper right hand corner
Run Code Online (Sandbox Code Playgroud)

我相信的另一个资源将帮助您更好地掌握边界框周围的基本思想: