PHP using JPG to generate animated GIF images _php tutorial

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:

01

02//a sequence of pictures that define JPG

03$filelist = Array (

"1.jpg",

' 2.jpg ',

' 3.jpg ',

' 4.jpg '

08);

09$type = ' gif ';

10$num = 200;

11$qian = ' New_ ';

12$path = './gif/';

13$is = 1;

14//a function to generate GIF pictures

15get_img ($filelist, $type, $num, $qian, $path, $is);

16/*

* get_img Pictures merged to generate GIF dynamic

* $filelist array of images to be merged

* $type Generated type

* The number of frames generated $num

* $qian new filename prefix

* $path Hold Path

* $is Preview

24 */

25function get_img ($filelist, $type, $num, $qian, $path, $is)

26{

27//Initialize class

$animation = new Imagick ();

29//Set the generated format

$animation->setformat ($type);

-foreach ($filelist as $file) {

$image = new Imagick ();

$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

37}

38//The following two lines are used for debugging, testing whether a GIF picture is generated

//header ("Content-type:image/gif");

//echo ($animation->getimagesblob ());

41//generated GIF file name combination

$images = $qian. Time (). '.' . $type;

43//Create GIF pictures

$animation->writeimages ($images, true);

45//Save GIF to specified folder

Copy ($images, $path. $images);

47//Whether preview

if ($is)

49 {

Echo ' has generated a GIF image: '. $images. '

';

echo "


";

52}

+ Else

54 {

Echo ' has generated a GIF image: '. $images. '

';

56}

57//Delete the original saved picture

Unlink ($images);

59}

60?>

http://www.bkjia.com/PHPjc/755619.html www.bkjia.com true http://www.bkjia.com/PHPjc/755619.html techarticle 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 .....

  • 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.