exif_thumbnail
(PHP 4 >= 4.2.0, PHP 5)
exif_thumbnail -- 取得嵌入在 TIFF 或 JPEG 图像中的缩略图
说明
string
exif_thumbnail
( string filename [, int &width [, int &height [, int &imagetype]]] )
exif_thumbnail()
读取 TIFF 或 JPEG
图像中的嵌入缩略图。如果图像不包含缩略图则返回
FALSE
。
参数
width
,
height
和
imagetype
自 PHP 4.3.0
起可用,返回缩略图的大小和类型。有可能
exif_thumbnail()
不能创建图像但可以测定其大小,此情况下返回值是
FALSE
,但是
width
和
height
的值已经传回了。
如果想用此函数发送缩略图,应该用
header()
函数发送 mime 类型信息。下面的例子演示了此方法:
例子 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"
;
}
?>
|
|
自 PHP 4.3.0 起,
exif_thumbnail()
函数可以以
TIFF
格式返回缩略图。
注:
本函数仅在 PHP 编译时使用了
--enable-exif
选项时可用。其功能和行为在
PHP 4.2 改变了。
参见
exif_read_data()
和
image_type_to_mime_type()
。