exif_thumbnail

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

exif_thumbnail取得嵌入在 TIFF 或 JPEG 圖像中的縮略圖

說(shuō)明

exif_thumbnail(
    string $filename,
    int &$width = ?,
    int &$height = ?,
    int &$imagetype = ?
): string

exif_thumbnail() 讀取 TIFFJPEG 圖像中的嵌入縮略圖。如果圖像不包含縮略圖則返回 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.

參數(shù)

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.

更新日志

版本 說(shuō)明
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";
}
?>

參見(jiàn)

  • exif_read_data() - 從一個(gè)圖片文件中讀取 EXIF 頭信息
  • image_type_to_mime_type() - 取得 getimagesize,exif_read_data,exif_thumbnail,exif_imagetype 所返回的圖像類(lèi)型的 MIME 類(lèi)型