(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)
exif_thumbnail — Retrieve the embedded thumbnail of an image
$file,&$width = null,&$height = null,&$image_type = nullexif_thumbnail() reads the embedded thumbnail of an image.
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.
filewidthheightimage_typeReturns the embedded thumbnail, or false if the image contains no thumbnail.
| Version | Description |
|---|---|
| 7.2.0 | The file parameter now supports both local files and stream resources. |
Example #1 exif_thumbnail() example
<?php
$image = exif_thumbnail('/path/to/image.jpg', $width, $height, $type);
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';
}
?>Note: If the
fileis used to pass a stream to this function, then the stream must be seekable. Note that the file pointer position is not changed after this function returns.