Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 2793

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Reads the EXIF headers from JPEG or TIFF</title>

 </head>
 <body><div class="manualnavbar" 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><hr /><div id="function.exif-read-data" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">exif_read_data</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5)</p><p class="refpurpose"><span class="refname">exif_read_data</span> &mdash; <span class="dc-title">Reads the <acronym title="Exchangeable Image File ">EXIF</acronym> headers from <acronym title="Joint Photographic Experts Group">JPEG</acronym> or <acronym title="Tagged Image File Format">TIFF</acronym></span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.exif-read-data-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><strong>exif_read_data</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$sections</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$arrays</code><span class="initializer"> = false</span></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$thumbnail</code><span class="initializer"> = false</span></span>
  ]]] )</div>

  <p class="para rdfs-comment">
    <span class="function"><strong>exif_read_data()</strong></span> reads the
   <acronym title="Exchangeable Image File ">EXIF</acronym> headers from a <acronym title="Joint Photographic Experts Group">JPEG</acronym> or 
   <acronym title="Tagged Image File Format">TIFF</acronym> image file.  This way you can read meta data 
   generated by digital cameras.
  </p>
  <p class="para">
   <acronym title="Exchangeable Image File ">EXIF</acronym> headers tend to be present in JPEG/TIFF images generated by digital
   cameras, but unfortunately each digital camera maker has a different
   idea of how to actually tag their images, so you can&#039;t always rely on
   a specific Exif header being present.
  </p>
  <p class="para">
   <em>Height</em> and <em>Width</em> are computed the 
   same way  <span class="function"><a href="function.getimagesize.html" class="function">getimagesize()</a></span> does so their values must not be 
   part of any header returned.  Also, <em>html</em> is a 
   height/width text string to be used inside normal <acronym title="Hyper Text Markup Language">HTML</acronym>.
  </p>
  <p class="para">
   When an Exif header contains a Copyright note, this itself can contain two
   values. As the solution is inconsistent in the Exif 2.10 standard, the
   <em>COMPUTED</em> section will return both entries
   <em>Copyright.Photographer</em> and
   <em>Copyright.Editor</em> while the <em>IFD0</em>
   sections contains the byte array with the NULL character that splits both
   entries. Or just the first entry if the datatype was wrong (normal behaviour
   of Exif). The <em>COMPUTED</em> will also contain the entry
   <em>Copyright</em> which is either the original copyright string,
   or a comma separated list of the photo and editor copyright.
  </p>
  <p class="para">
   The tag <em>UserComment</em> has the same problem as the Copyright
   tag. It can store two values.  First the encoding used, and second the value
   itself. If so the <em>IFD</em> section only contains the encoding
   or a byte array. The <em>COMPUTED</em> section will store both in
   the entries <em>UserCommentEncoding</em> and
   <em>UserComment</em>. The entry <em>UserComment</em>
   is available in both cases so it should be used in preference to the value
   in <em>IFD0</em> section.
  </p>
  <p class="para">
    <span class="function"><strong>exif_read_data()</strong></span> also validates EXIF data tags according
   to the EXIF specification (<a href="http://exif.org/Exif2-2.PDF" class="link external">&raquo;&nbsp;http://exif.org/Exif2-2.PDF</a>, page 20).
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Windows Me/XP can both wipe the Exif headers when connecting to a camera.
   </p>
  </p></blockquote>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.exif-read-data-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">filename</code></em></span>
     <dd>

      <p class="para">
       The name of the image file being read.  This cannot be an
       <acronym title="Uniform Resource Locator">URL</acronym>.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">sections</code></em></span>
     <dd>

      <p class="para">
       Is a comma separated list of sections that need to be present in file 
       to produce a result <span class="type"><a href="language.types.array.html" class="type array">array</a></span>.  If none of the requested 
       sections could be found the return value is <strong><code>FALSE</code></strong>.
       <table class="doctable informaltable">
        
         <tbody class="tbody">
          <tr>
           <td>FILE</td>
           <td>FileName, FileSize, FileDateTime, SectionsFound</td>
          </tr>

          <tr>
           <td>COMPUTED</td>
           <td>
            html, Width, Height, IsColor, and more if available.  Height and 
            Width are computed the same way  <span class="function"><a href="function.getimagesize.html" class="function">getimagesize()</a></span>
            does so their values must not be part of any header returned. 
            Also, <em>html</em> is a height/width text string to be used inside normal 
            <acronym title="Hyper Text Markup Language">HTML</acronym>.
           </td>
          </tr>

          <tr>
           <td>ANY_TAG</td>
           <td>Any information that has a Tag e.g. <em>IFD0</em>, <em>EXIF</em>, ...</td>
          </tr>

          <tr>
           <td>IFD0</td>
           <td>
            All tagged data of IFD0. In normal imagefiles this contains
            image size and so forth.
           </td>
          </tr>

          <tr>
           <td>THUMBNAIL</td>
           <td>
            A file is supposed to contain a thumbnail if it has a second <em>IFD</em>.
            All tagged information about the embedded thumbnail is stored in 
            this section.
           </td>
          </tr>

          <tr>
           <td>COMMENT</td>
           <td>Comment headers of JPEG images.</td>
          </tr>

          <tr>
           <td>EXIF</td>
           <td>
            The EXIF section is a sub section of <em>IFD0</em>. It contains
            more detailed information about an image. Most of these entries
            are digital camera related.
           </td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">arrays</code></em></span>
      <dd>

      <p class="para">
       Specifies whether or not each section becomes an array. The 
       <em><code class="parameter">sections</code></em> <em>COMPUTED</em>,
       <em>THUMBNAIL</em>, and <em>COMMENT</em> 
       always become arrays as they may contain values whose names conflict
       with other sections.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">thumbnail</code></em></span>
     <dd>

      <p class="para">
       When set to <strong><code>TRUE</code></strong> the thumbnail itself is read.  Otherwise, only the
       tagged data is read.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>
    
 <div class="refsect1 returnvalues" id="refsect1-function.exif-read-data-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   It returns an associative <span class="type"><a href="language.types.array.html" class="type array">array</a></span> 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, 
    <span class="function"><strong>exif_read_data()</strong></span> will return <strong><code>FALSE</code></strong>.
  </p>
 </div>

 <div class="refsect1 changelog" id="refsect1-function.exif-read-data-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>4.3.0</td>
       <td>
        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 <em>THUMBNAIL</em> 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>
       <td>4.3.0</td>
       <td>
        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 <em>Unicode</em> or <em>JIS</em> encoding this encoding will 
        automatically be changed according to the exif ini settings in 
        <var class="filename">php.ini</var>
       </td>
      </tr>

      <tr>
       <td>4.3.0</td>
       <td>
        If the image contains any <em>IFD0</em> data then
        <em>COMPUTED</em> contains the entry
        <em>ByteOrderMotorola</em> which is 0 for
        <em>little-endian</em> (intel) and 1 for
        <em>big-endian</em> (motorola) byte order.  Also,
        <em>COMPUTED</em> and <em>UserComment</em> no 
        longer only contain the first copyright entry if the datatype was 
        wrong.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.exif-read-data-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-3163">
    <p><strong>Example #1  <span class="function"><strong>exif_read_data()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"test1.jpg:&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$exif&nbsp;</span><span style="color: #007700">=&nbsp;</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">,&nbsp;</span><span style="color: #DD0000">'IFD0'</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$exif</span><span style="color: #007700">===</span><span style="color: #0000BB">false&nbsp;</span><span style="color: #007700">?&nbsp;</span><span style="color: #DD0000">"No&nbsp;header&nbsp;data&nbsp;found.&lt;br&nbsp;/&gt;\n"&nbsp;</span><span style="color: #007700">:&nbsp;</span><span style="color: #DD0000">"Image&nbsp;contains&nbsp;headers&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$exif&nbsp;</span><span style="color: #007700">=&nbsp;</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">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"test2.jpg:&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />foreach&nbsp;(</span><span style="color: #0000BB">$exif&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$key&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$section</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;foreach&nbsp;(</span><span style="color: #0000BB">$section&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$name&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$key</span><span style="color: #DD0000">.</span><span style="color: #0000BB">$name</span><span style="color: #DD0000">:&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #DD0000">&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #0000BB">?&gt;</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 screen">
<div class="cdata"><pre>
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=&quot;1&quot; height=&quot;1&quot;
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
</pre></div>
    </div>
   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.exif-read-data-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.exif-thumbnail.html" class="function" rel="rdfs-seeAlso">exif_thumbnail()</a> - Retrieve the embedded thumbnail of a TIFF or JPEG image</span></li>
    <li class="member"> <span class="function"><a href="function.getimagesize.html" class="function" rel="rdfs-seeAlso">getimagesize()</a> - Get the size of an image</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" 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>