imagecreate()返回一个表示指定大小的空白图像的图像标识符。

 

语法

PHP imagecreate()函数具有以下语法。

resource imagecreate ( int $width , int $height )

 

参数

PHP imagecreate()函数具有以下参数。

  • width - 图像宽度。
  • height - 图像高度。

 

返回值

成功时返回图像资源标识符,错误时返回FALSE。

 

实例1

<?php
/*
http://www.manongjc.com/article/1751.html
作者:码农教程
*/
header(\"Content-Type: image/png\");
$im = @imagecreate(110, 20)
    or die(\"Cannot Initialize new GD image stream\");
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  \"A Simple Text String\", $text_color);
imagepng($im);
imagedestroy($im);
?>

 

实例2

最基本的图像脚本如下所示:

将以下代码保存为picture.php

<?PHP
$image = imagecreate(400,300);
// do stuff to the image
imagejpeg($image, \'\', 75);
imagedestroy($image);
?>

将以下代码保存为viewPicture.htm:

<html>
 <body>
     <img src = “picture1.php” />
 </ body>
</ html>
收藏 打印