reference/exif/functions/exif-read-data.xml
f57352dd7a678230f929e1bac0d4a9189631cf16
...
...
@@ -4,21 +4,20 @@
4
4
<refentry xml:id="function.exif-read-data" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5
5
<refnamediv>
6
6
<refname>exif_read_data</refname>
7
-
<refpurpose>Reads the <acronym>EXIF</acronym> headers from <acronym>JPEG</acronym> or <acronym>TIFF</acronym></refpurpose>
7
+
<refpurpose>Reads the <acronym>EXIF</acronym> headers from an image file</refpurpose>
8
8
</refnamediv>
9
9
<refsect1 role="description">
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
-
<type>array</type><methodname>exif_read_data</methodname>
13
-
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
14
-
<methodparam choice="opt"><type>string</type><parameter>sections</parameter><initializer>&null;</initializer></methodparam>
15
-
<methodparam choice="opt"><type>bool</type><parameter>arrays</parameter><initializer>false</initializer></methodparam>
16
-
<methodparam choice="opt"><type>bool</type><parameter>thumbnail</parameter><initializer>false</initializer></methodparam>
12
+
<type class="union"><type>array</type><type>false</type></type><methodname>exif_read_data</methodname>
13
+
<methodparam><type class="union"><type>resource</type><type>string</type></type><parameter>file</parameter></methodparam>
14
+
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>required_sections</parameter><initializer>&null;</initializer></methodparam>
15
+
<methodparam choice="opt"><type>bool</type><parameter>as_arrays</parameter><initializer>&false;</initializer></methodparam>
16
+
<methodparam choice="opt"><type>bool</type><parameter>read_thumbnail</parameter><initializer>&false;</initializer></methodparam>
17
17
</methodsynopsis>
18
18
<para>
19
19
<function>exif_read_data</function> reads the
20
-
<acronym>EXIF</acronym> headers from a <acronym>JPEG</acronym> or
21
-
<acronym>TIFF</acronym> image file. This way you can read meta data
20
+
<acronym>EXIF</acronym> headers from an image file. This way you can read meta data
22
21
generated by digital cameras.
23
22
</para>
24
23
<para>
...
...
@@ -60,27 +59,23 @@
60
59
to the EXIF specification (<link
61
60
xlink:href="&url.exifspec;">&url.exifspec;</link>, page 20).
62
61
</para>
63
-
<note>
64
-
<para>
65
-
Windows Me/XP can both wipe the Exif headers when connecting to a camera.
66
-
</para>
67
-
</note>
68
62
</refsect1>
69
63
<refsect1 role="parameters">
70
64
&reftitle.parameters;
71
65
<para>
72
66
<variablelist>
73
67
<varlistentry>
74
-
<term><parameter>filename</parameter></term>
68
+
<term><parameter>file</parameter></term>
75
69
<listitem>
76
70
<para>
77
-
The name of the image file being read. This cannot be an
78
-
<acronym>URL</acronym>.
71
+
The location of the image file. This can either be a path to the file
72
+
(stream wrappers are also supported as usual)
73
+
or a stream <type>resource</type>.
79
74
</para>
80
75
</listitem>
81
76
</varlistentry>
82
77
<varlistentry>
83
-
<term><parameter>sections</parameter></term>
78
+
<term><parameter>required_sections</parameter></term>
84
79
<listitem>
85
80
<para>
86
81
Is a comma separated list of sections that need to be present in file
...
...
@@ -141,11 +136,11 @@
141
136
</listitem>
142
137
</varlistentry>
143
138
<varlistentry>
144
-
<term><parameter>arrays</parameter></term>
139
+
<term><parameter>as_arrays</parameter></term>
145
140
<listitem>
146
141
<para>
147
142
Specifies whether or not each section becomes an array. The
148
-
<parameter>sections</parameter> <literal>COMPUTED</literal>,
143
+
<parameter>required_sections</parameter> <literal>COMPUTED</literal>,
149
144
<literal>THUMBNAIL</literal>, and <literal>COMMENT</literal>
150
145
always become arrays as they may contain values whose names conflict
151
146
with other sections.
...
...
@@ -153,7 +148,7 @@
153
148
</listitem>
154
149
</varlistentry>
155
150
<varlistentry>
156
-
<term><parameter>thumbnail</parameter></term>
151
+
<term><parameter>read_thumbnail</parameter></term>
157
152
<listitem>
158
153
<para>
159
154
When set to &true; the thumbnail itself is read. Otherwise, only the
...
...
@@ -173,6 +168,16 @@
173
168
<function>exif_read_data</function> will return &false;.
174
169
</para>
175
170
</refsect1>
171
+

172
+
<refsect1 role="errors">
173
+
&reftitle.errors;
174
+
<para>
175
+
Errors of level <constant>E_WARNING</constant> and/or <constant>E_NOTICE</constant>
176
+
may be raised for unsupported tags or other potential error conditions, but the
177
+
function still tries to read all comprehensible information.
178
+
</para>
179
+
</refsect1>
180
+

176
181
<refsect1 role="changelog">
177
182
&reftitle.changelog;
178
183
<para>
...
...
@@ -186,37 +191,37 @@
186
191
</thead>
187
192
<tbody>
188
193
<row>
189
-
<entry>4.3.0</entry>
194
+
<entry>8.0.0</entry>
190
195
<entry>
191
-
Can read all embedded <acronym>IFD</acronym> data including arrays
192
-
(returned as such). Also the size of an embedded thumbnail is
193
-
returned in a <literal>THUMBNAIL</literal> subarray, and can
194
-
return thumbnails in <acronym>TIFF</acronym> format. Also, there is
195
-
no longer a maximum length for returned values (not until the memory
196
-
limit has been reached)
196
+
<parameter>required_sections</parameter> is nullable now.
197
197
</entry>
198
198
</row>
199
199
<row>
200
-
<entry>4.3.0</entry>
200
+
<entry>7.2.0</entry>
201
201
<entry>
202
-
If PHP has <link linkend="ref.mbstring">mbstring</link> support,
203
-
the user comment can automatically change encoding. Also, if the
204
-
user comment uses <literal>Unicode</literal> or <literal>JIS</literal> encoding this encoding will
205
-
automatically be changed according to the exif ini settings in
206
-
&php.ini;
202
+
The <parameter>file</parameter> parameter now supports both local files
203
+
and stream resources.
207
204
</entry>
208
205
</row>
209
206
<row>
210
-
<entry>4.3.0</entry>
207
+
<entry>7.2.0</entry>
211
208
<entry>
212
-
If the image contains any <literal>IFD0</literal> data then
213
-
<literal>COMPUTED</literal> contains the entry
214
-
<literal>ByteOrderMotorola</literal> which is 0 for
215
-
<literal>little-endian</literal> (intel) and 1 for
216
-
<literal>big-endian</literal> (motorola) byte order. Also,
217
-
<literal>COMPUTED</literal> and <literal>UserComment</literal> no
218
-
longer only contain the first copyright entry if the datatype was
219
-
wrong.
209
+
<para>
210
+
Support for the following EXIF formats were added:
211
+
<simplelist>
212
+
<member>Samsung</member>
213
+
<member>DJI</member>
214
+
<member>Panasonic</member>
215
+
<member>Sony</member>
216
+
<member>Pentax</member>
217
+
<member>Minolta</member>
218
+
<member>Sigma/Foveon</member>
219
+
<member>AGFA</member>
220
+
<member>Kyocera</member>
221
+
<member>Ricoh</member>
222
+
<member>Epson</member>
223
+
</simplelist>
224
+
</para>
220
225
</entry>
221
226
</row>
222
227
</tbody>
...
...
@@ -284,6 +289,75 @@ THUMBNAIL.Thumbnail.Height: 1
284
289
</screen>
285
290
</example>
286
291
</para>
292
+
<para>
293
+
<example>
294
+
<title><function>exif_read_data</function> with streams available as of PHP 7.2.0</title>
295
+
<programlisting role="php">
296
+
<![CDATA[
297
+
<?php
298
+
// Open a the file, this should be in binary mode
299
+
$fp = fopen('/path/to/image.jpg', 'rb');
300
+

301
+
if (!$fp) {
302
+
echo 'Error: Unable to open image for reading';
303
+
exit;
304
+
}
305
+

306
+
// Attempt to read the exif headers
307
+
$headers = exif_read_data($fp);
308
+

309
+
if (!$headers) {
310
+
echo 'Error: Unable to read exif headers';
311
+
exit;
312
+
}
313
+

314
+
// Print the 'COMPUTED' headers
315
+
echo 'EXIF Headers:' . PHP_EOL;
316
+

317
+
foreach ($headers['COMPUTED'] as $header => $value) {
318
+
printf(' %s => %s%s', $header, $value, PHP_EOL);
319
+
}
320
+
?>
321
+
]]>
322
+
</programlisting>
323
+
&example.outputs.similar;
324
+
<screen role="php">
325
+
<![CDATA[
326
+
EXIF Headers:
327
+
Height => 576
328
+
Width => 1024
329
+
IsColor => 1
330
+
ByteOrderMotorola => 0
331
+
ApertureFNumber => f/5.6
332
+
UserComment =>
333
+
UserCommentEncoding => UNDEFINED
334
+
Copyright => Denis
335
+
Thumbnail.FileType => 2
336
+
Thumbnail.MimeType => image/jpeg
337
+
]]>
338
+
</screen>
339
+
</example>
340
+
</para>
341
+
</refsect1>
342
+
<refsect1 role="notes">
343
+
&reftitle.notes;
344
+
<note>
345
+
<para>
346
+
If <link linkend="ref.mbstring">mbstring</link> is enabled, exif will attempt to process
347
+
the unicode and pick a charset as specified by
348
+
<link linkend="ini.exif.decode-unicode-motorola">exif.decode_unicode_motorola</link> and
349
+
<link linkend="ini.exif.decode-unicode-intel">exif.decode_unicode_intel</link>. The exif
350
+
extension will not attempt to figure out the encoding on its own, and it is up to the user
351
+
to properly specify the encoding for which to use for decoding by setting one of these two
352
+
ini directives prior to calling <function>exif_read_data</function>.
353
+
</para>
354
+
</note>
355
+
<note>
356
+
<para>
357
+
If the <parameter>file</parameter> is used to pass a stream to this function, then the stream
358
+
must be seekable. Note that the file pointer position is not changed after this function returns.
359
+
</para>
360
+
</note>
287
361
</refsect1>
288
362
<refsect1 role="seealso">
289
363
&reftitle.seealso;
...
...
@@ -291,11 +365,11 @@ THUMBNAIL.Thumbnail.Height: 1
291
365
<simplelist>
292
366
<member><function>exif_thumbnail</function></member>
293
367
<member><function>getimagesize</function></member>
368
+
<member><xref linkend="wrappers"/></member>
294
369
</simplelist>
295
370
</para>
296
371
</refsect1>
297
372
</refentry>
298
-

299
373
<!-- Keep this comment at the end of the file
300
374
Local variables:
301
375
mode: sgml
302
376