CCode for Artists - Miles DeCoster

EXIF (Exchangeable Image Format) is a common metadata format for digital cameras. It stores a lot of information about the camera and each picture taken as part of the image file. Note that metadata is sometimes deleted by image compression software to minimize files size. In PHP the date can be read and is returned as an array. To access a specific piece of information just get the value for the approriate key in the array.

For example: to get the model name of the camera you would use:

<?php 
$exif_data = exif_read_data('chaparral2f.jpg');
$modelName = $exif_data['Model'];
echo ('<p>The picture was taken with a '.$modelName.'.</p>');
?>

This returns:

The picture was taken with a Canon EOS DIGITAL REBEL XT.

To display the full array returned from: exif_read_data('chaparral2f.jpg')

<?php
$sourceImage = "chaparral2f.jpg";
echo ('<pre>');
$exif_data = exif_read_data($sourceImage);
print_r($exif_data);
echo ('</pre>');
?>

This results in:

Array
(
    [FileName] => chaparral2f.jpg
    [FileDateTime] => 1357319174
    [FileSize] => 53097
    [FileType] => 2
    [MimeType] => image/jpeg
    [SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF, INTEROP
    [COMPUTED] => Array
        (
            [html] => width="800" height="533"
            [Height] => 533
            [Width] => 800
            [IsColor] => 1
            [ByteOrderMotorola] => 0
            [CCDWidth] => 5mm
            [ApertureFNumber] => f/9.0
            [UserComment] => 
            [UserCommentEncoding] => UNDEFINED
            [Copyright] => ©2012 Miles DeCoster
            [Thumbnail.FileType] => 2
            [Thumbnail.MimeType] => image/jpeg
        )

    [ImageWidth] => 3456
    [ImageLength] => 2304
    [BitsPerSample] => Array
        (
            [0] => 8
            [1] => 8
            [2] => 8
        )

    [PhotometricInterpretation] => 2
    [Make] => Canon
    [Model] => Canon EOS DIGITAL REBEL XT
    [Orientation] => 1
    [SamplesPerPixel] => 3
    [XResolution] => 720000/10000
    [YResolution] => 720000/10000
    [ResolutionUnit] => 2
    [Software] => Adobe Photoshop CS5 Macintosh
    [DateTime] => 2013:01:04 12:05:28
    [Artist] => Miles DeCoster
    [WhitePoint] => Array
        (
            [0] => 313/1000
            [1] => 329/1000
        )

    [PrimaryChromaticities] => Array
        (
            [0] => 64/100
            [1] => 33/100
            [2] => 21/100
            [3] => 71/100
            [4] => 15/100
            [5] => 6/100
        )

    [YCbCrCoefficients] => Array
        (
            [0] => 299/1000
            [1] => 587/1000
            [2] => 114/1000
        )

    [YCbCrPositioning] => 2
    [Copyright] => ©2012 Miles DeCoster
    [Exif_IFD_Pointer] => 484
    [THUMBNAIL] => Array
        (
            [Compression] => 6
            [XResolution] => 72/1
            [YResolution] => 72/1
            [ResolutionUnit] => 2
            [JPEGInterchangeFormat] => 1350
            [JPEGInterchangeFormatLength] => 3052
        )

    [ExposureTime] => 1/100
    [FNumber] => 90/10
    [ExposureProgram] => 4
    [ISOSpeedRatings] => 400
    [ExifVersion] => 0221
    [DateTimeOriginal] => 2012:12:11 14:42:31
    [DateTimeDigitized] => 2012:12:11 14:42:31
    [ComponentsConfiguration] => 
    [ShutterSpeedValue] => 435412/65536
    [ApertureValue] => 415488/65536
    [ExposureBiasValue] => 0/2
    [MaxApertureValue] => 4/1
    [MeteringMode] => 5
    [Flash] => 16
    [FocalLength] => 33/1
    [UserComment] => 
    [FlashPixVersion] => 0100
    [ColorSpace] => 65535
    [ExifImageWidth] => 800
    [ExifImageLength] => 533
    [InteroperabilityOffset] => 1224
    [FocalPlaneXResolution] => 3456000/874
    [FocalPlaneYResolution] => 2304000/582
    [FocalPlaneResolutionUnit] => 2
    [CustomRendered] => 0
    [ExposureMode] => 0
    [WhiteBalance] => 0
    [SceneCaptureType] => 0
    [UndefinedTag:0xA500] => 22/10
    [InterOperabilityIndex] => R03
    [InterOperabilityVersion] => 0100
)

©copyright 2013 Miles DeCoster