PHP 中的 imagecreate() 函数
imagecreate() 函数用于创建新图像。建议使用 imagecreatetruecolor() 代替 imagecreate() 来创建图像。这是因为图像处理在使用 imagecreatetruecolor() 创建的质量最好的图像上执行。
语法
imagecreate( $width, $height )
参数
width: 图像的宽度
height: 图像的高度
返回
imagecreate() 函数成功时返回图像资源标识符,错误时返回 FALSE。
示例
以下是一个示例
<?php
$img = imagecreate(500, 300);
$bgcolor = imagecolorallocate($img, 150, 200, 180);
$fontcolor = imagecolorallocate($img, 120, 60, 200);
imagestring($img, 12, 150, 120, "Demo Text1", $fontcolor);
imagestring($img, 3, 150, 100, "Demo Text2", $fontcolor);
imagestring($img, 9, 150, 80, "Demo Text3", $fontcolor);
imagestring($img, 12, 150, 60, "Demo Text4", $fontcolor);
header("Content-Type: image/png");
imagepng($img);
imagedestroy($img);
?>输出
以下是输出

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP