search
Homephp教程php手册php通过exif_read_data函数获取图片的exif信息

php通过exif_read_data函数获取图片的exif信息

   这篇文章主要介绍了php通过exif_read_data函数获取图片的exif信息,默认情况下,PHP读取图片Exif信息模块是不开启的,我们需要先开启这个模块。开启Exif模块需要mbstring支持,这里就不详细说明了,我们来先看下函数的用法

  php获取图片的exif信息,php自带一个exif_read_data函数可以用来读取图片的exif信息,代码来自php手册

  ?

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

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

  以上所述就是本文的全部内容了,希望大家能够喜欢。

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software