首頁  >  文章  >  後端開發  >  php取得圖片的exif訊息

php取得圖片的exif訊息

WBOY
WBOY原創
2016-07-25 08:45:141011瀏覽
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


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn