PHP使用JPG產生GIF動畫圖片,基於php_imagick_st-Q8.dll

來源:互聯網
上載者:User

標籤:

PHP使用php_imagick_st-Q8.dll類庫,把JPG圖片串連產生GIF動畫圖片,需要事先下載好php_imagick_st-Q8.dll,檔案,並配置php.ini檔案,啟用php_imagick_st-Q8.dll。配置方法如下:

1、將下載的php_imagick_st-Q8.dll檔案放到PHP預設的擴充目錄,也就是:php/ext/目錄內;

2、開啟php.ini,在extension地區新加入此行,注意前面不要有“;”

extension=php_imagick_st-Q8.dll

3、重啟apache或IIS。

4、PHP函數如下:

<?php//定義JPG的圖片序列$filelist = array(    ‘1.jpg‘,    ‘2.jpg‘,    ‘3.jpg‘,    ‘4.jpg‘);$type = ‘gif‘;$num  = 200;$qian = ‘new_‘;$path = ‘./gif/‘;$is = 1;//產生gif圖片的函數get_img($filelist, $type, $num, $qian, $path, $is);/* * get_img  圖片合并,產生gif動態 * $filelist 要合并的圖片數組 * $type 產生的類型 * $num 產生的幀數 * $qian 新檔案名稱首碼 * $path 保持路徑 * $is 是否預覽 */function get_img($filelist, $type, $num, $qian, $path, $is){ //初始化類 $animation = new Imagick(); //設定產生的格式 $animation->setFormat($type); foreach ( $filelist as $file ){  $image = new Imagick();  $image->readImage( $file );    //合并圖片  $animation->addImage( $image );  //加入到對象  $animation->setImageDelay($num); //設定圖片幀數  unset( $image );       //清除記憶體裡的映像,釋放記憶體 } //以下兩行是調試時用的,測試是否產生了gif圖片 //header( "Content-Type: image/gif" ); //echo( $animation->getImagesBlob() ); //產生的GIF檔案名稱組合 $images = $qian . time(). ‘.‘ . $type; //產生GIF圖片 $animation->writeImages( $images,true ); //儲存GIF到指定檔案夾 copy($images, $path . $images); //是否預覽 if($is) {  echo ‘已產生gif圖片: ‘ . $images . ‘<br />‘;  echo "<img src=‘" . $path . $images . "‘ />"; } else {  echo ‘已產生gif圖片: ‘ . $images . ‘<br />‘; } //刪除原來儲存的圖片 unlink($images);}?>

 

PHP使用JPG產生GIF動畫圖片,基於php_imagick_st-Q8.dll

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.