如何通过PHP的imagestring()函数在图像上水平添加文本字符串?
- 内容介绍
- 文章标签
- 相关推荐
本文共计142个文字,预计阅读时间需要1分钟。
示例代码如下:
php// 创建图像或空白图像$width=700;$height=300;$image=imagecreate($width, $height);
// 设置图像背景颜色$background_color=imagecolorallocate($image, 122, 122, 122);
// 设置文本颜色$text_color=imagecolorallocate($image, 255, 255, 255);
例子2<?php // Create the size of the image or blank image $img = imagecreate(700, 300); // Set the background color of the image $background_color = imagecolorallocate($img, 122, 122, 122); // Set the text color of the image $text_color = imagecolorallocate($img, 255, 255, 0); // Function to create an image that contains a string. imagestring($img, 10, 30, 60,"Tutorialspoint:Simply Easy Learning", $text_color); header("Content-Type: image/png"); imagepng($img); imagedestroy($img); ?>输出
本文共计142个文字,预计阅读时间需要1分钟。
示例代码如下:
php// 创建图像或空白图像$width=700;$height=300;$image=imagecreate($width, $height);
// 设置图像背景颜色$background_color=imagecolorallocate($image, 122, 122, 122);
// 设置文本颜色$text_color=imagecolorallocate($image, 255, 255, 255);
例子2<?php // Create the size of the image or blank image $img = imagecreate(700, 300); // Set the background color of the image $background_color = imagecolorallocate($img, 122, 122, 122); // Set the text color of the image $text_color = imagecolorallocate($img, 255, 255, 0); // Function to create an image that contains a string. imagestring($img, 10, 30, 60,"Tutorialspoint:Simply Easy Learning", $text_color); header("Content-Type: image/png"); imagepng($img); imagedestroy($img); ?>输出

