php通过exif_read_data函数获取图片的exif信息
程序员文章站
2023-01-05 22:57:55
php获取图片的exif信息,php自带一个exif_read_data函数可以用来读取图片的exif信息,代码来自php手册
php获取图片的exif信息,php自带一个exif_read_data函数可以用来读取图片的exif信息,代码来自php手册
<?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', 0, true); echo "test2.jpg:<br />\n"; foreach ($exif as $key => $section) { foreach ($section as $name => $val) { echo "$key.$name: $val<br />\n"; } } ?>
输出结果如下
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
以上所述就是本文的全部内容了,希望大家能够喜欢。
上一篇: PHP图像处理类库MagickWand用法实例分析
下一篇: php使用标签替换的方式生成静态页面