This article mainly introduces PHP based on php_imagick_st-Q8.dll to achieve JPG synthesis GIF image method, the need of friends can refer to the next
I. Overview:
This article describes the PHP based on php_imagick_st-Q8.dll to achieve JPG synthesis GIF image method.
First of all to achieve PHP using the php_imagick_st-Q8.dll class library, the jpg image connection to generate GIF animation image, need to download the php_imagick_st-Q8.dll dynamic link library file in advance, and configure the php. ini file, enable the php_imagick_st-Q8.dll.
2. the configuration method is as follows:
1,Place the downloaded php_imagick_st-Q8.dll file in the PHP default extension directory, that is, the php/ext/Directory;
2. open php. ini and add a new line in the extension area. Note that there is no ";" in front, that is:
Extension = php_imagick_st-Q8.dll
3,Restart apache or IIS.
III. PHP implementation code:
<? Php // defines the JPG image sequence $ filelist = array ('1.jpg ', '2.jpg', '3.jpg ', '4.jpg'); $ type = 'GIF'; $ num = 200; $ qian = 'new _ '; $ path = '. /gif/'; $ is = 1; // The get_img function for generating gif images ($ filelist, $ type, $ num, $ qian, $ path, $ is ); /** get_img image merging, generate gif dynamic * $ filelist array of images to be merged * $ type generated type * $ number of frames generated by num * $ qian new file name prefix * $ path maintained path * $ is Preview * /function get_img ($ filelist, $ type, $ num, $ qian, $ path, $ is) {// Initialization class $ animation = new Imagick (); // Set the generated format $ animation-> setFormat ($ type); foreach ($ filelist as $ file) {$ image = new Imagick (); $ image-> readImage ($ file); // merge images $ animation-> addImage ($ image); // add to object $ animation-> setImageDelay ($ num ); // set the number of image frames unset ($ image); // clear the images in the memory and release the memory} // the following two lines are used for debugging, test whether a gif image is generated // header ("Content-Type: image/gif"); // echo ($ animation-> getImagesBlob ()); // The generated GIF file name combination $ images = $ qian. time (). '. '. $ type; // Generate GIF images $ animation-> writeImages ($ images, true); // save GIF to the specified folder copy ($ images, $ path. $ images); // whether to preview if ($ is) {echo 'generated GIF image :'. $ images.'
'; Echo "";} else {echo' generated GIF image: '. $ images .'
';} // Delete the unlink ($ images) of the original saved image;}?>