当前位置:Gxlcms > PHP教程 > php获取图片的exif信息

php获取图片的exif信息

时间:2021-07-01 10:21:17 帮助过:29人阅读

php获取图片的exif信息,php自带一个exif_read_data函数可以用来读取图片的exif信息
  1. echo "test1.jpg:
    \n";
  2. $exif = exif_read_data('tests/test1.jpg', 'IFD0');
  3. echo $exif===false ? "No header data found.
    \n" : "Image contains headers
    \n";
  4. $exif = exif_read_data('tests/test2.jpg', 0, true);
  5. echo "test2.jpg:
    \n";
  6. foreach ($exif as $key => $section) {
  7. foreach ($section as $name => $val) {
  8. echo "$key.$name: $val
    \n";
  9. }
  10. }
  11. ?>

输出结果如下
  1. test1.jpg:
  2. No header data found.
  3. test2.jpg:
  4. FILE.FileName: test2.jpg
  5. FILE.FileDateTime: 1017666176
  6. FILE.FileSize: 1240
  7. FILE.FileType: 2
  8. FILE.SectionsFound: ANY_TAG, IFD0, THUMBNAIL, COMMENT
  9. COMPUTED.html: width="1" height="1"
  10. COMPUTED.Height: 1
  11. COMPUTED.Width: 1
  12. COMPUTED.IsColor: 1
  13. COMPUTED.ByteOrderMotorola: 1
  14. COMPUTED.UserComment: Exif test image.
  15. COMPUTED.UserCommentEncoding: ASCII
  16. COMPUTED.Copyright: Photo (c) M.Boerger, Edited by M.Boerger.
  17. COMPUTED.Copyright.Photographer: Photo (c) M.Boerger
  18. COMPUTED.Copyright.Editor: Edited by M.Boerger.
  19. IFD0.Copyright: Photo (c) M.Boerger
  20. IFD0.UserComment: ASCII
  21. THUMBNAIL.JPEGInterchangeFormat: 134
  22. THUMBNAIL.JPEGInterchangeFormatLength: 523
  23. COMMENT.0: Comment #1.
  24. COMMENT.1: Comment #2.
  25. COMMENT.2: Comment #3end
  26. THUMBNAIL.JPEGInterchangeFormat: 134
  27. THUMBNAIL.Thumbnail.Height: 1
  28. THUMBNAIL.Thumbnail.Height: 1


php, exif

人气教程排行