<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >exif_read_data</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="Manual do PHP" HREF="index.html"><LINK REL="UP" TITLE="Exif Functions" HREF="ref.exif.html"><LINK REL="PREVIOUS" TITLE="exif_imagetype" HREF="function.exif-imagetype.html"><LINK REL="NEXT" TITLE="exif_tagname" HREF="function.exif-tagname.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Manual do PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.exif-imagetype.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.exif-tagname.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.exif-read-data" ></A >exif_read_data</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN44679" ></A ><P > (PHP 4 >= 4.2.0, PHP 5)</P >exif_read_data -- Reads the <ACRONYM CLASS="acronym" >EXIF</ACRONYM > headers from <ACRONYM CLASS="acronym" >JPEG</ACRONYM > or <ACRONYM CLASS="acronym" >TIFF</ACRONYM ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN44685" ></A ><H2 >Descrição</H2 >array <B CLASS="methodname" >exif_read_data</B > ( string filename [, string sections [, bool arrays [, bool thumbnail]]] )<BR ></BR ><P > <B CLASS="function" >exif_read_data()</B > reads the <ACRONYM CLASS="acronym" >EXIF</ACRONYM > headers from a <ACRONYM CLASS="acronym" >JPEG</ACRONYM > or <ACRONYM CLASS="acronym" >TIFF</ACRONYM > image file. This way you can read meta data generated by digital cameras. </P ><P > Exif 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't always rely on a specific Exif header being present. </P ><P > <TT CLASS="literal" >Height</TT > and <TT CLASS="literal" >Width</TT > are computed the same way <A HREF="function.getimagesize.html" ><B CLASS="function" >getimagesize()</B ></A > does so their values must not be part of any header returned. Also, <TT CLASS="literal" >html</TT > is a height/width text string to be used inside normal <ACRONYM CLASS="acronym" >HTML</ACRONYM >. </P ><P > 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 COMPUTED section will return both entries <TT CLASS="literal" >Copyright.Photographer</TT > and <TT CLASS="literal" >Copyright.Editor</TT > while the IFD0 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 COMPUTED will also contain the entry <TT CLASS="literal" >Copyright</TT > which is either the original copyright string, or a comma separated list of the photo and editor copyright. </P ><P > The tag UserComment 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 IFD section only contains the encoding or a byte array. The COMPUTED section will store both in the entries <TT CLASS="literal" >UserCommentEncoding</TT > and <TT CLASS="literal" >UserComment</TT >. The entry <TT CLASS="literal" >UserComment</TT > is available in both cases so it should be used in preference to the value in IFD0 section. </P ><P > <B CLASS="function" >exif_read_data()</B > also validates EXIF data tags according to the EXIF specification (<A HREF="http://exif.org/Exif2-2.PDF" TARGET="_top" >http://exif.org/Exif2-2.PDF</A >, page 20). </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Nota: </B > Windows ME/XP can both wipe the Exif headers when connecting to a camera. More information available at <A HREF="http://www.canon.co.jp/Imaging/NOTICE/011214-e.html" TARGET="_top" >http://www.canon.co.jp/Imaging/NOTICE/011214-e.html</A >. </P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN44728" ></A ><H2 >Parâmetros</H2 ><P > <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><CODE CLASS="parameter" >filename</CODE ></DT ><DD ><P > The name of the image file being read. This cannot be an <ACRONYM CLASS="acronym" >URL</ACRONYM >. </P ></DD ><DT ><CODE CLASS="parameter" >sections</CODE ></DT ><DD ><P > Is a comma separated list of sections that need to be present in file to produce a result <A HREF="language.types.array.html" ><B CLASS="type" >array</B ></A >. If none of the requested sections could be found the return value is <TT CLASS="constant" ><B >FALSE</B ></TT >. <DIV CLASS="informaltable" ><P ></P ><A NAME="AEN44745" ></A ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><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 <A HREF="function.getimagesize.html" ><B CLASS="function" >getimagesize()</B ></A > does so their values must not be part of any header returned. Also, html is a height/width text string to be used inside normal <ACRONYM CLASS="acronym" >HTML</ACRONYM >. </TD ></TR ><TR ><TD >ANY_TAG</TD ><TD >Any information that has a Tag e.g. IFD0, EXIF, ...</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 IFD. 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 IFD0. It contains more detailed information about an image. Most of these entries are digital camera related. </TD ></TR ></TBODY ></TABLE ><P ></P ></DIV > </P ></DD ><DT ><CODE CLASS="parameter" >arrays</CODE ></DT ><DD ><P > Specifies whether or not each section becomes an array. The <CODE CLASS="parameter" >sections</CODE > <TT CLASS="literal" >COMPUTED</TT >, <TT CLASS="literal" >THUMBNAIL</TT >, and <TT CLASS="literal" >COMMENT</TT > always become arrays as they may contain values whose names conflict with other sections. </P ></DD ><DT ><CODE CLASS="parameter" >thumbnail</CODE ></DT ><DD ><P > When set to <TT CLASS="constant" ><B >TRUE</B ></TT > the thumbnail itself is read. Otherwise, only the tagged data is read. </P ></DD ></DL ></DIV > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN44786" ></A ><H2 >Valores de retornado</H2 ><P > It returns an associative <A HREF="language.types.array.html" ><B CLASS="type" >array</B ></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 CLASS="function" >exif_read_data()</B > will return <TT CLASS="constant" ><B >FALSE</B ></TT >. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN44792" ></A ><H2 >Histórico</H2 ><P > <DIV CLASS="informaltable" ><P ></P ><A NAME="AEN44795" ></A ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><THEAD ><TR ><TH >Versão</TH ><TH >Descrição</TH ></TR ></THEAD ><TBODY ><TR ><TD >4.3.0</TD ><TD > Can read all embedded <ACRONYM CLASS="acronym" >IFD</ACRONYM > data including arrays (returned as such). Also the size of an embedded thumbnail is returned in a <TT CLASS="literal" >THUMBNAIL</TT > subarray, and can return thumbnails in <ACRONYM CLASS="acronym" >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" >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 <TT CLASS="filename" >php.ini</TT > </TD ></TR ><TR ><TD >4.3.0</TD ><TD > 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 ></TABLE ><P ></P ></DIV > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN44816" ></A ><H2 >Exemplos</H2 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN44819" ></A ><P ><B >Exemplo 1. <B CLASS="function" >exif_read_data()</B > example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /></font><font color="#007700">echo </font><font color="#DD0000">"test1.jpg:<br />\n"</font><font color="#007700">;<br /></font><font color="#0000BB">$exif </font><font color="#007700">= </font><font color="#0000BB">exif_read_data</font><font color="#007700">(</font><font color="#DD0000">'tests/test1.jpg'</font><font color="#007700">, </font><font color="#DD0000">'IFD0'</font><font color="#007700">);<br />echo </font><font color="#0000BB">$exif</font><font color="#007700">===</font><font color="#0000BB">false </font><font color="#007700">? </font><font color="#DD0000">"No header data found.<br />\n" </font><font color="#007700">: </font><font color="#DD0000">"Image contains headers<br />\n"</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$exif </font><font color="#007700">= </font><font color="#0000BB">exif_read_data</font><font color="#007700">(</font><font color="#DD0000">'tests/test2.jpg'</font><font color="#007700">, </font><font color="#0000BB">0</font><font color="#007700">, </font><font color="#0000BB">true</font><font color="#007700">);<br />echo </font><font color="#DD0000">"test2.jpg:<br />\n"</font><font color="#007700">;<br />foreach (</font><font color="#0000BB">$exif </font><font color="#007700">as </font><font color="#0000BB">$key </font><font color="#007700">=> </font><font color="#0000BB">$section</font><font color="#007700">) {<br /> foreach (</font><font color="#0000BB">$section </font><font color="#007700">as </font><font color="#0000BB">$name </font><font color="#007700">=> </font><font color="#0000BB">$val</font><font color="#007700">) {<br /> echo </font><font color="#DD0000">"$key.$name: $val<br /></font><font color="#007700">\n</font><font color="#DD0000">"</font><font color="#007700">;<br /> }<br />}<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ><P > The first call fails because the image has no header information. </P ><P >O exemplo acima irá imprimir algo similar a:</P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> test1.jpg:<br />No header data found.<br />test2.jpg:<br />FILE.FileName: test2.jpg<br />FILE.FileDateTime: 1017666176<br />FILE.FileSize: 1240<br />FILE.FileType: 2<br />FILE.SectionsFound: ANY_TAG, IFD0, THUMBNAIL, COMMENT<br />COMPUTED.html: width="1" height="1"<br />COMPUTED.Height: 1<br />COMPUTED.Width: 1<br />COMPUTED.IsColor: 1<br />COMPUTED.ByteOrderMotorola: 1<br />COMPUTED.UserComment: Exif test image.<br />COMPUTED.UserCommentEncoding: ASCII<br />COMPUTED.Copyright: Photo (c) M.Boerger, Edited by M.Boerger.<br />COMPUTED.Copyright.Photographer: Photo (c) M.Boerger<br />COMPUTED.Copyright.Editor: Edited by M.Boerger.<br />IFD0.Copyright: Photo (c) M.Boerger<br />IFD0.UserComment: ASCII<br />THUMBNAIL.JPEGInterchangeFormat: 134<br />THUMBNAIL.JPEGInterchangeFormatLength: 523<br />COMMENT.0: Comment #1.<br />COMMENT.1: Comment #2.<br />COMMENT.2: Comment #3end<br />THUMBNAIL.JPEGInterchangeFormat: 134<br />THUMBNAIL.Thumbnail.Height: 1<br />THUMBNAIL.Thumbnail.Height: 1</font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN44826" ></A ><H2 >Veja também</H2 ><P > <P ></P ><TABLE BORDER="0" ><TBODY ><TR ><TD ><A HREF="function.exif-thumbnail.html" ><B CLASS="function" >exif_thumbnail()</B ></A ></TD ></TR ><TR ><TD ><A HREF="function.getimagesize.html" ><B CLASS="function" >getimagesize()</B ></A ></TD ></TR ></TBODY ></TABLE ><P ></P > </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.exif-imagetype.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Principal</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.exif-tagname.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >exif_imagetype</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.exif.html" ACCESSKEY="U" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >exif_tagname</TD ></TR ></TABLE ></DIV ></BODY ></HTML >