PHP obtains the exif information of the image through the exif_read_data function_PHP tutorial

WBOY
Release: 2016-07-13 09:53:18
Original
1140 people have browsed it

php obtains the exif information of the image through the exif_read_data function

This article mainly introduces php to obtain the exif information of the image through the exif_read_data function. By default, PHP reads the image Exif information The module is not enabled, we need to enable this module first. Enabling the Exif module requires mbstring support. I won’t explain it in detail here. Let’s first look at the usage of the function

PHP gets 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 comes 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";

}

}

?>

1

2

3

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.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

4

5

6

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 results are 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.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
The above is the entire content of this article, I hope you all like it. http://www.bkjia.com/PHPjc/1003825.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1003825.htmlTechArticlephp obtains the exif information of the image through the exif_read_data function. This article mainly introduces php to obtain the exif information of the image through the exif_read_data function. , by default, PHP reads image Exif information...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template