首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

exif_thumbnail

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

exif_t​​humbnail - 检索图像的嵌入缩略图

描述

代码语言:javascript
复制
string exif_thumbnail ( mixed $stream [, int &$width [, int &$height [, int &$imagetype ]]] )

exif_t​​humbnail()读取图像的嵌入缩略图。

如果你想通过这个函数传递缩略图,你应该使用header()函数发送mimetype信息。

exif_thumbnail()可能无法创建图像,但可以确定其大小。 在这种情况下,返回值为FALSE,但设置了宽度和高度。

参数

stream

图像文件的位置。这可以是文件或流资源的路径。

width

返回的缩略图的返回宽度。

height

返回的缩略图的返回高度。

imagetype

返回的缩略图的返回图像类型。这是TIFF或JPEG。

返回值

返回嵌入的缩略图,如果图像不包含缩略图,则返回FALSE。

例子

示例#1 exif_t​​humbnail()示例

代码语言:javascript
复制
<?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';
}
?>

更新日志

描述

7.2.0

filename参数已重命名为流,现在支持本地文件或流资源。

扩展内容

  • exif_read_data() - 从图像文件中读取EXIF标头
  • image_type_to_mime_type() - 获取由getimagesize,exif_read_data,exif_t​​humbnail,exif_imagetype返回的图像类型的Mime-Type

← exif_tagname

read_exif_data →

扫码关注腾讯云开发者

领取腾讯云代金券