exif_thumbnail -- 取得嵌入在 TIFF 或 JPEG 图像中的缩略图
array exif_read_data ( string filename [, string sections [, bool arrays [, bool thumbnail]]] )
使用举例:
// 设置图片路径,必须是系统完整的路径
$dir = "/gallery";
//下面请注意exif_read_data读取的文件路径是与本程序所在位置相对的路径
$exif = exif_read_data('CIMG7348.jpg', 0, true);
echo "显示CIMG7348.jpg的元信息:
\n";
foreach ($exif as $key => $section) {
foreach ($section as $name => $val) {
echo "$key.$name: $val
\n";
}
}
?>
上面的代码执行后显示如下(其中EXIF.MakerNote会显示很长一段乱码,所以去除了):
CIMG7348.jpg:
FILE.FileName: CIMG7348.jpg
FILE.FileDateTime: 1043148976
FILE.FileSize: 1465229
FILE.FileType: 2
FILE.MimeType: image/jpeg
FILE.SectionsFound: ANY_TAG, IFD0, THUMBNAIL, EXIF, INTEROP
COMPUTED.html: width="2240" height="1680"
COMPUTED.Height: 1680
COMPUTED.Width: 2240
COMPUTED.IsColor: 1
COMPUTED.ByteOrderMotorola: 1
COMPUTED.ApertureFNumber: f/2.8
COMPUTED.Thumbnail.FileType: 2
COMPUTED.Thumbnail.MimeType: image/jpeg
IFD0.Make: CASIO COMPUTER CO.,LTD
IFD0.Model: QV-R40
IFD0.Orientation: 1
IFD0.XResolution: 72/1
IFD0.YResolution: 72/1
IFD0.ResolutionUnit: 2
IFD0.Software: 1.00
IFD0.DateTime: 2003:01:21 19:36:15
IFD0.YCbCrPositioning: 1
IFD0.Exif_IFD_Pointer: 276
IFD0.UndefinedTag:0xC4A5: PrintIM0250
THUMBNAIL.Compression: 6
THUMBNAIL.XResolution: 72/1
THUMBNAIL.YResolution: 72/1
THUMBNAIL.ResolutionUnit: 2
THUMBNAIL.JPEGInterchangeFormat: 32992
THUMBNAIL.JPEGInterchangeFormatLength: 8366
EXIF.ExposureTime: 1/125
EXIF.FNumber: 28/10
EXIF.ExposureProgram: 2
EXIF.ExifVersion: 0220
EXIF.DateTimeOriginal: 2003:01:21 19:36:15
EXIF.DateTimeDigitized: 2003:01:21 19:36:15
EXIF.ComponentsConfiguration:
EXIF.CompressedBitsPerPixel: 1468416/3763200
EXIF.ExposureBiasValue: 0/3
EXIF.MaxApertureValue: 30/10
EXIF.MeteringMode: 5
EXIF.LightSource: 0
EXIF.Flash: 16
EXIF.FocalLength: 800/100
EXIF.ColorSpace: 1
EXIF.ExifImageWidth: 2240
EXIF.ExifImageLength: 1680
EXIF.InteroperabilityOffset: 32868
EXIF.FileSource:
EXIF.CustomRendered: 0
EXIF.ExposureMode: 0
EXIF.WhiteBalance: 0
EXIF.DigitalZoomRatio: 0/0
EXIF.FocalLengthIn35mmFilm: 39
EXIF.SceneCaptureType: 0
EXIF.GainControl: 0
EXIF.Contrast: 0
EXIF.Saturation: 2
EXIF.Sharpness: 2
INTEROP.InterOperabilityIndex: R98
INTEROP.InterOperabilityVersion: 0100
用上面这种方法,可以在你不确定图片头有哪些信息名,和与其相应的值时,起到通览的作用。当然,你也可以在程序中调用指定的头信息:
echo "镜头类型:" . $exif['IFD0']['Model'];
从原始图片中提取缩略图,并显示的方法:
string exif_thumbnail ( string filename [, int &width [, int &height [, int &imagetype]]] )
$imgdat=exif_thumbnail('CIMG7348.jpg']);header('Content-type: '.image_type_to_mime_type(image/jpeg));
echo($imgdat);?>
详细内容可参考php的相关手册进行开发。
备注:
本站文章若非注明,均属原创。转载请保持文章完整性, 不足之处欢迎来信交流指教. 作者邮箱:nicekey@gmail.com 网站:http://erst.cn/