exif_thumbnail
(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)
exif_thumbnail — 取得嵌入在 TIFF 或 JPEG 影象中的縮圖
說明
string
$filename,int
&$width = ?,int
&$height = ?,int
&$imagetype = ?): string
exif_thumbnail() 讀取 TIFF 或 JPEG
影象中的嵌入縮圖。如果影象不包含縮圖則返回 false。
If you want to deliver thumbnails through this function, you should send the mimetype information using the header() function.
It is possible that exif_thumbnail() cannot create an
image but can determine its size. In this case, the return value is
false but width and height
are set.
參數
-
filename -
The name of the image file being read. This image contains an embedded thumbnail.
-
width -
The return width of the returned thumbnail.
-
height -
The returned height of the returned thumbnail.
-
imagetype -
The returned image type of the returned thumbnail. This is either TIFF or JPEG.
返回值
Returns the embedded thumbnail, or false if the image contains no
thumbnail.
更新日誌
| 版本 | 說明 |
|---|---|
| 4.3.0 |
The optional parameters width,
height, and imagetype
all became available.
|
| 4.3.0 | May return thumbnails in the TIFF format. |
範例
示例 #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";
}
?>
參見
- exif_read_data() - 從一個圖片檔案中讀取 EXIF 頭資訊
- image_type_to_mime_type() - 取得 getimagesize,exif_read_data,exif_thumbnail,exif_imagetype 所返回的影象型別的 MIME 型別