|
imagecreatefromgif (PHP 3, PHP 4, PHP 5) imagecreatefromgif -- 從 GIF 檔案或 URL 新增一圖像 說明resource imagecreatefromgif ( string filename )
imagecreatefromgif()
返回一圖像標識符,代表了從給定的檔案名取得的圖像。
imagecreatefromgif()
在失敗時返回一個空字串,並且輸出一條錯誤訊息,不幸地在瀏覽器中顯示為斷連結。為減輕除錯工作下面的例子會產生一個錯誤
GIF:
例子 1. 處理建立過程中的錯誤
<?php function LoadGif($imgname) { $im = @imagecreatefromgif($imgname); /* Attempt to open */ if(!$im) { /* See if it failed */ $im = imagecreatetruecolor(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 庫 1.6 版起所有的 GIF 支援都移除了,又在 GD 庫 2.0.28
版起又加了回來。若果使用二者之間版本的 GD 庫時本函數不可用。
| |