EXIF

 

Many image formats, especially JPEG, provide the ability to store textual (& binary thumbnail) metadata within the file itself. Digital cameras, scanners and other imaging equipment will often generate technical data and store it in a image more or less standard format know as the Exchangeable Image File Format or EXIF. Details can be found at http://www.exif.org/

if PHP has been compiled with --enable-exif, several functions become available to read EXIF data. Since EXIF data is related to the generation of image (see the example below), there is no need to write EXIF data, and none are provided.

int exif_imageType  ( string filename )
Reads the first bytes of an image and checks its signature. When a correct signature is found a constant will be returned otherwise the return value is FALSE. The return value is the same value that getImageSize() returns in index 2 but this function is much faster.
int exif_read_data  ( string filename [, string sections [, bool arrays [, bool thumbnail]]]
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 an url.
sections is a comma separated list of sections that need to be present in file to produce a result array
FILE FileName, FileSize, FileDateTime, SectionsFound
COMPUTED html, Width, Height, IsColor and some more if available.
ANY_TAG Any information that has a Tag e.g. IFD0, EXIF, ...
IFD0 All tagged data of IFD0. In normal image files this contains image size and so forth.
THUMBNAIIL 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.
COMMENT Comment headers of JPEG images.
EXIF 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.
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.

int read_exif_data  -- Alias of exif_read_data()
Description

<?PHP
print_r
(exif_read_data('AtTheLodge.jpg',ANY_TAG)) ;
?>
Array
(
    [FileName] => AtTheLodge.jpg
    [FileDateTime] => 1162167430
    [FileSize] => 69909
    [FileType] => 2
    [MimeType] => image/jpeg
    [SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF
    [COMPUTED] => Array
        (
            [html] => width="480" height="360"
            [Height] => 360
            [Width] => 480
            [IsColor] => 1
            [ByteOrderMotorola] => 1
            [ApertureFNumber] => f/2.6
            [Copyright] => (Copyright Notice)
            [Thumbnail.FileType] => 2
            [Thumbnail.MimeType] => image/jpeg
        )

    [ImageDescription] => Only one beer? (Capation)
    [Make] => PENTAX Corporation 
    [Model] => PENTAX Optio S 
    [Orientation] => 1
    [XResolution] => 72/1
    [YResolution] => 72/1
    [ResolutionUnit] => 2
    [Software] => Adobe Photoshop 7.0
    [DateTime] => 2003:10:29 17:16:34
    [Artist] => Jeff Knight (Author)
    [YCbCrPositioning] => 1
    [Copyright] => (Copyright Notice)
    [UndefinedTag:0xC4A5] => PrintIM0250
    [Exif_IFD_Pointer] => 380
    [THUMBNAIL] => Array
        (
            [Compression] => 6
            [XResolution] => 72/1
            [YResolution] => 72/1
            [ResolutionUnit] => 2
            [JPEGInterchangeFormat] => 938
            [JPEGInterchangeFormatLength] => 5368
        )

    [ExposureTime] => 1/40
    [FNumber] => 26/10
    [ExposureProgram] => 2
    [ExifVersion] => 0220
    [DateTimeOriginal] => 2003:08:22 22:21:05
    [DateTimeDigitized] => 2003:08:22 22:21:05
    [ComponentsConfiguration] => 
    [CompressedBitsPerPixel] => 2048000/3145728
    [ExposureBiasValue] => 0/3
    [MaxApertureValue] => 28/10
    [MeteringMode] => 5
    [LightSource] => 0
    [Flash] => 73
    [FocalLength] => 580/100
    [FlashPixVersion] => 0100
    [ColorSpace] => 65535
    [ExifImageWidth] => 480
    [ExifImageLength] => 360
    [FileSource] => 
    [CustomRendered] => 0
    [ExposureMode] => 0
    [WhiteBalance] => 0
    [DigitalZoomRatio] => 0/0
    [FocalLengthIn35mmFilm] => 35
    [SceneCaptureType] => 0
    [GainControl] => 0
    [Contrast] => 0
    [Saturation] => 0
    [Sharpness] => 0
    [SubjectDistanceRange] => 0
)
int exif_thumbnail  ( string filename [, int &width [, int &height [, int &imagetype]]] )
Reads the embedded thumbnail of a TIFF or JPEG image. If the image contains no thumbnail FALSE will be returned.
The parameters width, height and imagetype are available since PHP 4.3.0 and return the size of the thumbnail as well as its type. It is possible that exif_thumbnail() cannot create an image but can determine its size. In this case, the return value is FALSE but width and height are set.
If you want to deliver thumbnails through this function, you should send the mimetype information using the header() function.

Starting from version PHP 4.3.0, the function exif_thumbnail() can return thumbnails in TIFF format.