📄 function.exif-read-data.html
字号:
<span class="term"><i><tt class="parameter">arrays</tt></i></span> <dd> <p class="para"> Specifies whether or not each section becomes an array. The <i><tt class="parameter">sections</tt></i> <i>COMPUTED</i>, <i>THUMBNAIL</i>, and <i>COMMENT</i> always become arrays as they may contain values whose names conflict with other sections. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">thumbnail</tt></i></span> <dd> <p class="para"> When set to <b><tt>TRUE</tt></b> the thumbnail itself is read. Otherwise, only the tagged data is read. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> It returns an associative <a href="language.types.array.html" class="type array">array</a> where the array indexes are the header names and the array values are the values associated with those headers. If no data can be returned, <b>exif_read_data()</b> will return <b><tt>FALSE</tt></b>. </p> </div> <div class="refsect1 changelog"> <h3 class="title">ChangeLog</h3> <p class="para"> <table class="informaltable"> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Version</th> <th colspan="1">Description</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">4.3.0</td> <td colspan="1" rowspan="1" align="left"> Can read all embedded <acronym title="Image File Directory">IFD</acronym> data including arrays (returned as such). Also the size of an embedded thumbnail is returned in a <i>THUMBNAIL</i> subarray, and can return thumbnails in <acronym title="Tagged Image File Format">TIFF</acronym> format. Also, there is no longer a maximum length for returned values (not until the memory limit has been reached) </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">4.3.0</td> <td colspan="1" rowspan="1" align="left"> If PHP has <a href="ref.mbstring.html" class="link">mbstring</a> support, the user comment can automatically change encoding. Also, if the user comment uses Unicode or JIS encoding this encoding will automatically be changed according to the exif ini settings in <var class="filename">php.ini</var> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">4.3.0</td> <td colspan="1" rowspan="1" align="left"> If the image contains any IFD0 data then COMPUTED contains the entry ByteOrderMotorola which is 0 for little-endian (intel) and 1 for big-endian (motorola) byte order. Also, COMPUTED and UserComment no longer only contain the first copyright entry if the datatype was wrong. </td> </tr> </tbody> </colgroup> </table> </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 <b>exif_read_data()</b> example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">"test1.jpg:<br />\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$exif </span><span style="color: #007700">= </span><span style="color: #0000BB">exif_read_data</span><span style="color: #007700">(</span><span style="color: #DD0000">'tests/test1.jpg'</span><span style="color: #007700">, </span><span style="color: #DD0000">'IFD0'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$exif</span><span style="color: #007700">===</span><span style="color: #0000BB">false </span><span style="color: #007700">? </span><span style="color: #DD0000">"No header data found.<br />\n" </span><span style="color: #007700">: </span><span style="color: #DD0000">"Image contains headers<br />\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$exif </span><span style="color: #007700">= </span><span style="color: #0000BB">exif_read_data</span><span style="color: #007700">(</span><span style="color: #DD0000">'tests/test2.jpg'</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">true</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"test2.jpg:<br />\n"</span><span style="color: #007700">;<br />foreach (</span><span style="color: #0000BB">$exif </span><span style="color: #007700">as </span><span style="color: #0000BB">$key </span><span style="color: #007700">=> </span><span style="color: #0000BB">$section</span><span style="color: #007700">) {<br /> foreach (</span><span style="color: #0000BB">$section </span><span style="color: #007700">as </span><span style="color: #0000BB">$name </span><span style="color: #007700">=> </span><span style="color: #0000BB">$val</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">"$key.$name: $val<br />\n"</span><span style="color: #007700">;<br /> }<br />}<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> <div class="example-contents"><p> The first call fails because the image has no header information. </p></div> <div class="example-contents"><p>The above example will output something similar to:</p></div> <div class="example-contents"><pre><div class="cdata"><pre>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</pre></div> </pre></div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.exif-thumbnail.html" class="function" rel="rdfs-seeAlso">exif_thumbnail()</a></li> <li class="member"><a href="function.getimagesize.html" class="function" rel="rdfs-seeAlso">getimagesize()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.exif-imagetype.html">exif_imagetype</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.exif-tagname.html">exif_tagname</a></div> <div class="up"><a href="ref.exif.html">Exif Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -