圖形函式庫

ImageCreateFromGIF

(PHP3 , PHP4)

ImageCreateFromGIF ---  從檔案或URL建立一個新的圖形

語法 : int imagecreatefromgif (string filename)

說明 : 

ImageCreateFromGIF( )傳回一個圖形 identifier,表示從給予的檔名中獲得圖形。

ImageCreateFromGIF( )失敗時則傳回一個空字串,它也會傳回一個錯誤訊息,這個錯誤訊息不幸地顯示出像是瀏灠器中一個斷裂的連結,下面的範例將會產生出一個簡易除錯的圖形。

Example :

<?php

    function LoadGif ($imgname) { 

                  $im = @ImageCreateFromGIF ($imgname);      /* Attempt to open */ 

                  if (!$im) {      /* See if it failed */ 

                         $im = ImageCreate (150, 30);      /* Create a blank image */ 

                         $bgc = ImageColorAllocate ($im, 255, 255, 255); 

                         $tc = ImageColorAllocate ($im, 0, 0, 0); 

                         ImageFilledRectangle ($im, 0, 0, 150, 30, $bgc);

                         /* Output an errmsg */ 

                         ImageString ($im, 1, 5, 5, "Error loading $imgname", $tc); 

                   }

                   return $im; 

      }

?>

注意 : GD library在1.6之後的版本已經將所有提供的GIF給移除了 ,所以如果你是使用1.6之後的版本的話,則無法使用此函式


上一頁 首頁 下一頁