Home  >  Article  >  Backend Development  >  Create GIF using PHP_PHP tutorial

Create GIF using PHP_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:26:50888browse

PHP can be used for more than just creating HTML output. It can also be used to create GIF graphic files and even create simpler GIF image streams. To do this, you will need to use the GD library to compile the PHP source files.
Example 2-2. Use PHP to create GIF files
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);
?>
This example will be called by a page using a method similar to: Create GIF using PHP_PHP tutorial. The script about button.php3 will overlay this text on the basic graphic (in this case "images/button1.gif") and then output the resulting graphic. This is a very convenient way to prevent the button graphic from being redrawn every time the user wants to change the button's text. Using this approach, they will be used dynamically.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/531917.htmlTechArticlePHP can not only be used to create HTML output. It can also be used to create GIF graphic files and even create simpler GIF image streams. To do this, you will need to use the GD library to compile...
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