imagestringup
(PHP 4, PHP 5, PHP 7, PHP 8)
imagestringup — 垂直绘制字符串
说明
在指定坐标处垂直绘制 string
。
参数
-
image
由图象创建函数(例如imagecreatetruecolor())返回的 GdImage 对象。
-
font
取值对于内建的 latin2 编码字体可以是:1、2、3、4、5(更高的数字对应更大的字体), 或是通过 imageloadfont() 返回的 GdFont 实例。
x
-
左下角的 x 坐标。
y
-
左下角的 y 坐标。
string
-
要写入的字符串。
color
-
颜色标识符使用 imagecolorallocate() 创建。
更新日志
版本 | 说明 |
---|---|
8.1.0 |
font 参数现在接受 GdFont
实例和 int,之前仅接受 int。
|
8.0.0 |
image 现在需要 GdImage 实例;之前需要有效的 gd resource。
|
示例
示例 #1 imagestringup() 示例
<?php
// 创建 100*100 图像
$im = imagecreatetruecolor(100, 100);
// 写入文本
$textcolor = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
imagestringup($im, 3, 40, 80, 'gd library', $textcolor);
// 保存图像
imagepng($im, './stringup.png');
?>
以上示例的输出类似于:

参见
- imagestring() - 水平绘制字符串
- imageloadfont() - 载入新字体
+添加备注
用户贡献的备注 1 note
Anonymous ¶
22 years ago
function imagestringdown(&$image, $font, $x, $y, $s, $col)
{
$width = imagesx($image);
$height = imagesy($image);
$text_image = imagecreate($width, $height);
$white = imagecolorallocate ($text_image, 255, 255, 255);
$black = imagecolorallocate ($text_image, 0, 0, 0);
$transparent_colour = $white;
if ($col == $white)
$transparent_color = $black;
imagefill($text_image, $width, $height, $transparent_colour);
imagecolortransparent($text_image, $transparent_colour);
imagestringup($text_image, $font, ($width - $x), ($height - $y), $s, $col);
imagerotate($text_image, 180.0, $transparent_colour);
imagecopy($image, $text_image, 0, 0, 0, 0, $width, $height);
}
备份地址:http://www.lvesu.com/blog/php/function.imagestringup.php