The method of JPG synthesis of GIF image based on php_imagick_st-Q8.dll in PHP

Source: Internet
Author: User
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;}?>

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.