发布于 2023-11-27 00:54:08 浏览 108 次
array imagettfbbox(float $size, float $angle, string $fontfile, string $text)
$fontFile = '/path/to/font.ttf';
$text = 'Hello, World!';
$size = 24;
$angle = 0;
$bbox = imagettfbbox($size, $angle, $fontFile, $text);
// 提取边界框的坐标
$x1 = $bbox[0];
$y1 = $bbox[1];
$x2 = $bbox[2];
$y2 = $bbox[3];
$x3 = $bbox[4];
$y3 = $bbox[5];
$x4 = $bbox[6];
$y4 = $bbox[7];
// 输出边界框的尺寸
$width = $x2 - $x1;
$height = $y2 - $y1;
echo "Bounding box width: $width\n";
echo "Bounding box height: $height\n";