Problems and workarounds for dynamic GIF generation using PHP _php tutorial

Source: Internet
Author: User
PHP does not stipulate that only HTML files are output, it can generate animated GIF files. I encountered some problems when using PHP to dynamically generate GIF images, which I have now resolved, and I am using php4.05 (for Win32) +apache3.1.2_win32.

Problem one: Dynamically generated GIF programs don't turn up at all

I wrote an example of using PHP to generate GIF, run, found that the page is not brush out, as if dead, the browser does not have any error prompts.

Workaround: Modify the php.ini in the directory where PHP is located

Through the house Orso near Network member Selo help, tell me is to modify the installation of PHP under the path of php.ini (note: Must be the PHP path php.ini) extension_dir = Install PHP path Extensions (for example: C: phpextensions).

Question two: Php_gd.dll does not support GIF

I loaded the Php_gd.dll Dynamic Connection Library at the beginning of the program: DL ("Php_gd.dll"), but there was a result when I ran the program:


Warning: Imagegif:no GIF Support in the PHP build in d:apachehtdocsgif2.php3 on line

Workaround: Use php4.05

Then I found that it was written in the book Php_gd.dll can not support the generation of GIF, after the expert guidance to know their version of php4.04 for Win32 lack of PHP_GD_ Gif.dll, so I downloaded a later version of php4.05, which has a php_gd_gif.dll that supports generating animated GIFs.

Issue three: Warning appears: Warning:function registration Failed-duplicate Name-imagearc in d:apachehtdocsgif2.php3 on line 3

The procedure is as follows:

DL ("Php_gd_gif.dll");
Header ("Content-type:image/gif");

$im = Imagecreate (400,30);
$black = Imagecolorallocate ($im, 0,0,0);
$white = Imagecolorallocate ($im, 255,255,255);
Imageline ($im, 200,15,215,15, $white);
Imagestring ($im, 5, 4, "This is a Gif", $white);

Imagegif ($im);
Imagedestroy ($im);


?>

Workaround: Modify the program or php.ini

The DL () function is used to load the DLL, but if the required DLL in the php.ini file is preceded by ";" If it has been removed, then do not use this function.
If the ";" in the INI file before Extension=php_gd_gif.dll Do not go, then use DL ("Php_gd_gif.dll"); load, in short: The two are different, or the server is considered to be a duplicate name.


http://www.bkjia.com/PHPjc/532474.html www.bkjia.com true http://www.bkjia.com/PHPjc/532474.html techarticle PHP does not stipulate that only HTML files are output, it can generate animated GIF files. I have encountered some problems when using PHP to generate GIF images dynamically, I have resolved, I use php4.05 (for Win32) +a ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.