PHP uses JPG to generate animated GIF images based on Php_imagick_st-q8.dll

Source: Internet
Author: User

PHP uses the Php_imagick_st-q8.dll class library, the JPG images connected to generate animated GIF images, you need to download the Php_imagick_st-q8.dll, file, and configure php.ini file, enable Php_imagick_ St-q8.dll. The configuration method is as follows:

1. Put the downloaded Php_imagick_st-q8.dll file in the PHP default extension directory, i.e.: php/ext/directory;

2, open php.ini, in the extension area to join this trip, note that the front does not have ";"

Extension=php_imagick_st-q8.dll

3. Restart Apache or IIS.

4. PHP functions are as follows:

<?PHP//a sequence of pictures that defines a JPG$filelist=Array(    ' 1.jpg ', ' 2.jpg ', ' 3.jpg ', ' 4.jpg ');$type= ' gif ';$num= 200;$qian= ' New_ ';$path= './gif/';$is= 1;//function to generate GIF picturesGet_img ($filelist,$type,$num,$qian,$path,$is);/** get_img picture merge, generate GIF dynamic * $filelist image array to merge * $type generated type * $num number of frames generated * $qian new filename prefix * $path keep path * $is preview*/functionGet_img ($filelist,$type,$num,$qian,$path,$is){ //Initialize class $animation=NewImagick ();//set the generated format $animation->setformat ($type); foreach($filelist  as $file ){  $image=NewImagick (); $image->readimage ($file);//Merging Pictures  $animation->addimage ($image);//Add to Object  $animation->setimagedelay ($num);//set the number of picture frames  unset($image);//clears the memory image and frees up memory } //The following two lines are used for debugging, whether the test generates a GIF picture//header ("Content-type:image/gif");//echo ($animation->getimagesblob ()); The generated GIF file name combination $images=$qian. Time(). ‘.‘ .$type; //create a GIF picture $animation->writeimages ($images,true ); //save GIF to a specified folder Copy($images,$path.$images); //whether to preview if($is) {  Echo' A GIF image has been generated: '.$images. ' <br/> '; Echo"$path.$images. "'/>"; } Else {  Echo' A GIF image has been generated: '.$images. ' <br/> '; } //Delete the original saved picture unlink($images);}?>

PHP uses JPG to generate animated GIF images based on Php_imagick_st-q8.dll

Related Article

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.