exif_read_data

(unknown)

exif_read_data -- Read the EXIF headers from JPEG or TIFF

Description

array exif_read_data ( string filename [, string sections [, bool arrays [, bool thumbnail]]])

The exif_read_data() function reads the EXIF headers from a JPEG or TIFF image file. It returns an associative array where the indexes are the header names and the values are the values associated with those headers. If no data can be returned the result is FALSE.

filename is the name of the file to read. This cannot be a url.

sections a comma separated lsit of sections that need to be present in file to produce a result array.

FILEFileName, FileSize, FileDateTime, SectionsFound
COMPUTEDhtml, 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.
COMMENTCemment 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 FILE, COMPUTED and THUMBNAIL allways 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.

Poznßmka: 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°φklad 1. exif_read_data() example

<?php
echo "test1.jpg:<br>\n";
$exif = exif_read_data ('tests/test1.jpg','IFD0');
echo $exif===false ? "No header data found.<br>\n" : "Image contains headers<br>";
$exif = exif_read_data ('tests/test2.jpg',0,true);
echo "test2.jpg:<br>\n";
foreach($exif as $key=>$section) {
    foreach($section as $name=>$val) {
        echo "$key.$name: $val<br>\n";
    }
}?>

The first call fails because the image has no header information.
test1.jpg:
No header data found.
test2.jpg:
FILE.FileName: test2.jpg
FILE.FileDateTime: 1015448798
FILE.FileSize: 1240
FILE.SectionsFound: COMPUTED, ANY_TAG, IFD0, THUMBNAIL, COMMENT
COMPUTED.Copyright.Photographer: Photo (c) M.Boerger
COMPUTED.Copyright.Editor: Edited by M.Boerger.
COMPUTED.html: width="1" height="1"
COMPUTED.Height: 1
COMPUTED.Width: 1
COMPUTED.IsColor: 1
COMPUTED.UserComment: Exif test image.
COMPUTED.UserCommentEncoding: ASCII
IFD0.Copyright: Photo (c) M.Boerger
IFD0.UserComment: ASCII
THUMBNAIL.JPEGInterchangeFormatLength: 523
COMMENT.0: Comment #1.
COMMENT.1: Comment #2.
COMMENT.2: Comment #3end?>

Poznßmka: When an Exif header contains a Copyright note this itself can contain two values. As the solution is inconsitent 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.

Poznßmka: The 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.

Poznßmka: 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 a normal HTML.

Poznßmka: Starting from PHP 4.3 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.

Poznßmka: This function is only available in PHP 4 compiled using --enable-exif. Its functionality and behaviour has changed in PHP 4.2. Earlier versions are very unstable.

This function does not require the GD image library.

See also exif_thumbnail() and GetImageSize().