PHP based on php_imagick_st-q8.dll implement JPG synthesis gif picture method _php Skill

Source: Internet
Author: User

First, overview:

This article describes the PHP based on php_imagick_st-q8.dll implementation of JPG GIF image synthesis method.
First of all to implement PHP using the Php_imagick_st-q8.dll class library, the JPG image connection to generate GIF animated pictures, you need to download the Php_imagick_st-q8.dll dynamic link library files, and configure php.ini files, enable PHP _imagick_st-q8.dll.

Second, the configuration method is as follows:

1, will download the Php_imagick_st-q8.dll file to the PHP default extension directory, namely: php/ext/directory ;
2, open php.ini, in the extension area new join this trip, pay attention to the front do not have ";", namely:
Extension=php_imagick_st-q8.dll
3, restart Apache or IIS.

Three, the PHP implementation code is as follows:

<?php//define JPG's picture sequence $filelist = Array (' 1.jpg ', ' 2.jpg ', ' 3.jpg ', ' 4.jpg ');
$type = ' gif ';
$num = 200;
$qian = ' New_ ';
$path = './gif/';
$is = 1;
Functions that generate GIF images get_img ($filelist, $type, $num, $qian, $path, $is); * * get_img picture merge, generate GIF dynamic * $filelist an array of pictures to merge * $type generated type * $num number of frames generated * $qian new filename prefix * $path keep path * $is Preview *
 /function Get_img ($filelist, $type, $num, $qian, $path, $is) {//Initialize class $animation = new Imagick ();
 Sets the generated format $animation->setformat ($type);
 foreach ($filelist as $file) {$image = new Imagick ();  $image->readimage ($file); Merge pictures $animation->addimage ($image); Add to Object $animation->setimagedelay ($num);    Set Picture frame number unset ($image);
 Clear the memory of the image, free memory}//The following two lines are used for debugging, test whether the generated GIF image//header ("Content-type:image/gif");
 Echo ($animation->getimagesblob ()); The generated GIF file name combination $images = $qian. Time (). '.' .
 $type;
 Generates a GIF picture $animation->writeimages ($images, true);
 Save GIF to the specified folder copy ($images, $path. $images); Whether to preview if ($is) {echo ' has generated a GIF picture: '. $images.
 ' <br/> '; echo " ';
//Delete the original saved picture unlink ($images); }?>

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.