首頁 > 後端開發 > php教程 > php取得圖片的exif資訊的範例程式碼

php取得圖片的exif資訊的範例程式碼

WBOY
發布: 2016-07-25 08:55:48
原創
852 人瀏覽過
  1. /**
  2. * 获取图片的exif信息
  3. * edit: bbs.it-home.org
  4. */
  5. echo "test1.jpg:
    n";
  6. $exif = exif_read_data('tests/test1.jpg', 'IFD0');
  7. echo $exif===false ? "No header data found.
    n" : "Image contains headers
    n";
  8. $exif = exif_read_data('tests/test2.jpg', 0, true);
  9. echo "test2.jpg:
    n";
  10. foreach ($exif as $key => $section) {
  11. foreach ($section as $name => $val) {
  12. echo "$key.$name: $val
    n";
  13. }
  14. }
  15. ?>
复制代码

输出结果:

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.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板