Php uses the exif_read_data function to obtain the exif information of an image.

Source: Internet
Author: User
This article describes how to use the exif_read_data function in php to obtain the exif information of an image. by default, PHP does not enable the Exif information module for reading images. we need to enable this module first. To enable the Exif module, mbstring support is required. we will use php to obtain the exif information of the image. The php built-in exif_read_data function can be used to read the exif information of the image. the code is from the php Manual.

<?phpecho "test1.jpg:
\n";$exif = exif_read_data('tests/test1.jpg', 'IFD0');echo $exif===false ? "No header data found.
\n" : "Image contains headers
\n"; $exif = exif_read_data('tests/test2.jpg', 0, true);echo "test2.jpg:
\n";foreach ($exif as $key => $section) { foreach ($section as $name => $val) { echo "$key.$name: $val
\n"; }}?>

The output result is as follows:

test1.jpg:No header data found.test2.jpg:FILE.FileName: test2.jpgFILE.FileDateTime: 1017666176FILE.FileSize: 1240FILE.FileType: 2FILE.SectionsFound: ANY_TAG, IFD0, THUMBNAIL, COMMENTCOMPUTED.html: width="1" height="1"COMPUTED.Height: 1COMPUTED.Width: 1COMPUTED.IsColor: 1COMPUTED.ByteOrderMotorola: 1COMPUTED.UserComment: Exif test image.COMPUTED.UserCommentEncoding: ASCIICOMPUTED.Copyright: Photo (c) M.Boerger, Edited by M.Boerger.COMPUTED.Copyright.Photographer: Photo (c) M.BoergerCOMPUTED.Copyright.Editor: Edited by M.Boerger.IFD0.Copyright: Photo (c) M.BoergerIFD0.UserComment: ASCIITHUMBNAIL.JPEGInterchangeFormat: 134THUMBNAIL.JPEGInterchangeFormatLength: 523COMMENT.0: Comment #1.COMMENT.1: Comment #2.COMMENT.2: Comment #3endTHUMBNAIL.JPEGInterchangeFormat: 134THUMBNAIL.Thumbnail.Height: 1THUMBNAIL.Thumbnail.Height: 1

The above is all the content of this article. I hope you will like it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.