exif_read_dataReads the EXIF headers from JPEG
or TIFF
&reftitle.description;
arrayexif_read_datastringfilenamestringsectionsboolarraysboolthumbnail
The exif_read_data function reads the
EXIF headers from a JPEG or
TIFF image file. This way you can read meta data
generated by digital cameras.
filename is the name of the file to read. This
cannot be a URL.
sections is a comma separated list of sections that
need to be present in file to produce a result array. If none of the
requested sections could be found the return value is &false;.
FILEFileName, FileSize, FileDateTime, SectionsFoundCOMPUTEDhtml, Width, Height, IsColor and some more if available.
ANY_TAGAny information that has a Tag e.g. IFD0, EXIF, ...IFD0All tagged data of IFD0. In normal imagefiles this contains
image size and so forth.THUMBNAILA 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.COMMENTComment headers of JPEG images.EXIFThe EXIF section is a sub section of IFD0. It contains
more detailed information about an image. Most of these entries
are digital camera related.arrays specifies whether or not each section
becomes an array. The sections COMPUTED,
THUMBNAIL and COMMENT always
become arrays as they may contain values whose names are conflict
with other sections.
thumbnail whether or not to read the thumbnail
itself and not only its tagged data.
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.
Windows ME/XP both can wipe the Exif headers when connecting to a camera.
More information available at &url.winexif;.
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. This was added in PHP 4.3.0.
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 Copyright.Photographer
and Copyright.Editor 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 contain also an entry Copyright Which
is either the original copyright string or it is a comma separated list of
photo and editor copyright.
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 UserCommentEncoding and
UserComment. The entry UserComment
is available in both cases so it should be used in preference to the value
in IFD0 section.
If the user comment uses Unicode or JIS encoding and the module mbstring is
available this encoding will automatically changed according to the exif
ini settings in the &php.ini;. This was added in PHP 4.3.0.
Height and Width are computed the same way getimagesize
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 HTML.
Starting from PHP 4.3.0, the function can read all embedded
IFD data including arrays (returned as such). Also
the size of an embedded thumbnail is returned in
THUMBNAIL subarray and the function
exif_read_data can return thumbnails in
TIFF format. Also as of PHP 4.3.0 there is no longer
a maximum length for returned values (not until memory limit is reached).
Since PHP 4.3,0 user comment can automatically change encoding if PHP was
compiled using .
&reftitle.returnvalues;
It returns an associative array 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,
exif_read_data will return &false;.
&reftitle.examples;
exif_read_data example
\n";
$exif = exif_read_data('tests/test1.jpg', 'IFD0');
echo $exif===false ? "No header data found. \n" : "Image contains headers ";
$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";
}
}
?>
]]>
The first call fails because the image has no header information.
&reftitle.seealso;
exif_thumbnail&listendand;
getimagesize.