Home  >  Article  >  php教程  >  使用PHP建立GIF

使用PHP建立GIF

WBOY
WBOYOriginal
2016-06-13 10:26:52900browse

PHP并不仅仅可以用来建立HTML输出。它还可以用来制作GIF图形文件,甚至制作更简便的GIF图象流。要想这样做,您将需要使用GD函数库来编译PHP源文件。
Example 2-2. 使用PHP来创建GIF文件
Header("Content-type: image/gif");
$string=implode($argv," ");
$im = imagecreatefromgif("images/button1.gif");
$orange = ImageColorAllocate($im, 220, 210, 60);
$px = (imagesx($im)-7.5*strlen($string))/2;
ImageString($im,3,$px,9,$string,$orange);
ImageGif($im);
ImageDestroy($im);
?>
这个例子将被一个页面使用类似于:的方法来调用。其中关于button.php3的脚本将把这一段文本覆盖在基本的图形上(在这里是“images/button1.gif”)然后输出结果图形。这是一个很简便的方法来防止每当用户希望改变按键的文本时候都重新画一次按钮图形。使用这种方法,他们将被动态的使用。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP语法Next article:用PHP实现POP3邮件的收取三