Php uses the exif_read_data function to obtain the exif information of an image _ PHP Tutorial

Source: Internet
Author: User
Php uses the exif_read_data function to obtain the exif information of an image. Php uses the exif_read_data function to obtain the exif information of an image. This article mainly introduces how php obtains the exif information of an image through the exif_read_data function. by default, PHP reads Image Exif information. php uses the exif_read_data function to obtain Image exif information.

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. Enabling the Exif module requires the support of mbstring, which is not described in detail here. let's take a look at the usage of the function.

Php obtains the exif information of the image. php comes with an exif_read_data function that can be used to read the exif information of the image. the code is from the php Manual.

?

1

2

3

4

5

6

7

8

9

10

11

12

13

Echo "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:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

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. fig: 134

THUMBNAIL. fig length: 523

COMMENT.0: Comment #1.

COMMENT.1: Comment #2.

COMMENT.2: Comment # 3end

THUMBNAIL. fig: 134

THUMBNAIL. Thumbnail. Height: 1

THUMBNAIL. Thumbnail. Height: 1

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

This article describes how php obtains the exif information of an image through the exif_read_data function. by default, PHP reads the Exif information of an image...

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.