梦幻屋

软件搜索:

Linux系统环境下如何使用PHP处理图像

更新时间: 2006-3-1 13:42:07 来源: 天极yesky  作者: 曹江华 Add to ToLib.com...
  •   Linux系统环境下如何使用PHP处理图像......

 

    三、创建图像步骤

  在PHP中创建一个图像通常需要以下四个步骤:

  1. 创建一个背景图像,以后所以操作但是基于此背景。

  2. 在图像上绘图轮廓或或者输入文本。

  3. 输出最终图形。

  4. 清除内存中所有资源。

  下面我们看一个应用实例,一个带“PHP”标签的正方型。脚本如下:

<?php

$height = 300;

$width = 300;

$im = ImageCreateTrueColor($width, $height);

$white = ImageColorAllocate ($im, 255, 255, 255);

$blue = ImageColorAllocate ($im, 0, 0, 64);

ImageFill($im, 0, 0, $blue);

ImageLine($im, 0, 0, $width, $height, $white);

ImageString($im, 4, 80, 150, 'PHP', $white);

Header ('Content-type: image/png');

ImagePng ($im);

ImageDestroy($im);

?>

  最后把这一小段脚本保存为si1.php,然后用浏览器对它进行访问,就可以看到一个300×300像素大小的PNG格式的图像,见图3。

Linux系统环境下如何使用PHP处理图像(3)

图3 PNG图像格式输出到浏览器的界面

上一页  [1] [2] [3] [4] [5] [6] 下一页

梦幻屋
  • 上一篇文章:
  • 梦幻屋学院
    Copyright© 2005-2006 梦幻工作室版权所有. All rights reserved.
    经营许可证编号:蜀ICP备07002423