說明
string
exif_thumbnail ( string filename [, int &width [, int &height [, int &imagetype]]] )
exif_thumbnail() 讀取 TIFF 或 JPEG
圖像中的內嵌縮略圖。若果圖像不包括縮略圖則返回 FALSE。
參數 width,height
和 imagetype 自 PHP 4.3.0
起可用,返回縮略圖的大小和類型。有可能 exif_thumbnail()
不能建立圖像但可以測定其大小,此情況下返回值是 FALSE,但是
width 和 height 的值已經傳回了。
若果想用此函數傳送縮略圖,應該用
header() 函數傳送 mime 類型訊息。下面的例子演示了此方法:
例子 1. exif_thumbnail() 例子
<?php if (array_key_exists('file',$_REQUEST)) { $image = exif_thumbnail($_REQUEST['file'], $width, $height, $type); } else { $image = false; } if ($image!==false) { header("Content-type: ".image_type_to_mime_type($type)); echo $image; exit; } else { // no thumbnail available, handle the error here echo "No thumbnail available"; } ?>
|
|
自 PHP 4.3.0 起,exif_thumbnail()
函數可以以 TIFF 格式返回縮略圖。
注:
本函數僅在 PHP 編譯時使用了
--enable-exif 選項時可用。其功能和行為在
PHP 4.2 改變了。
參見 exif_read_data() 和
image_type_to_mime_type()。