php 获取图片exif信息的简单示例

前端之家收集整理的这篇文章主要介绍了php 获取图片exif信息的简单示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
PHP获取图片的exif信息感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编两巴掌来看看吧!
PHP获取图片的exif信息,PHP自带一个exif_read_data函数可以用来读取图片的exif信息,代码来自PHP手册

/**
 * PHP获取图片的exif信息
 *
 * @param 
 * @arrange 512-笔记网: www.www.jb51.cc
 **/
<?PHP
echo "test1.jpg:<br />\n";
$exif = exif_read_data('tests/test1.jpg','IFD0');
echo $exif===false ? "No header data found.<br />\n" : "Image contains headers<br />\n";
$exif = exif_read_data('tests/test2.jpg',true);
echo "test2.jpg:<br />\n";
foreach ($exif as $key => $section) {
	foreach ($section as $name => $val) {
		echo "$key.$name: $val<br />\n";
	}
}

/***   来自编程之家 jb51.cc(jb51.cc)   ***/
输出结果如下
test1.jpg:
No header data found.
test2.jpg:
FILE.FileName: test2.jpg
FILE.FileDateTime: 1017666176
FILE.FileSize: 1240
FILE.FileType: 2
FILE.SectionsFound: ANY_TAG,IFD0,THUMBNAIL,COMMENT
COMPUTED.html: width="1" height="1"
COMPUTED.Height: 1
COMPUTED.Width: 1
COMPUTED.IsColor: 1
COMPUTED.ByteOrderMotorola: 1
COMPUTED.UserComment: Exif test image.
COMPUTED.UserCommentEncoding: ASCII
COMPUTED.Copyright: Photo (c) M.Boerger,Edited by M.Boerger.
COMPUTED.Copyright.Photographer: Photo (c) M.Boerger
COMPUTED.Copyright.Editor: Edited by M.Boerger.
IFD0.Copyright: Photo (c) M.Boerger
IFD0.UserComment: ASCII
THUMBNAIL.JPEGInterchangeFormat: 134
THUMBNAIL.JPEGInterchangeFormatLength: 523
COMMENT.0: Comment #1.
COMMENT.1: Comment #2.
COMMENT.2: Comment #3end
THUMBNAIL.JPEGInterchangeFormat: 134
THUMBNAIL.Thumbnail.Height: 1
THUMBNAIL.Thumbnail.Height: 1
原文链接:https://www.f2er.com/php/528286.html

猜你在找的PHP相关文章