exif_thumbnail

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

exif_thumbnail取锟斤拷嵌锟斤拷锟斤拷 TIFF 锟斤拷 JPEG 图锟斤拷锟叫碉拷锟斤拷锟斤拷图

说锟斤拷

exif_thumbnail ( 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.

锟斤拷锟斤拷

Example #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() - 锟斤拷 JPEG 锟斤拷 TIFF 锟侥硷拷锟叫讹拷取 EXIF 头锟斤拷息
  • image_type_to_mime_type() - 取锟斤拷 getimagesize锟斤拷exif_read_data锟斤拷exif_thumbnail锟斤拷exif_imagetype 锟斤拷锟斤拷锟截碉拷图锟斤拷锟斤拷锟酵碉拷 MIME 锟斤拷锟斤拷