read Exif data with PHP

Tuesday 18th September 2007 11:37 PM

TAGS: PHP, exif

Exif data, is meta-data stored within digital photos which can provide very useful information such as the model of camera used to take it, right down to the exact settings used. PHP provides some inbuilt functionality to grab this data out of any image file which  has it.

Here is a quick example of how you might do it. There are hundreds of pieces of data you can select, but these are probably some of the more commonly sought after.

<?

    
// read data
    
$exif exif_read_data('IMG_1242.jpg''IFD0');

    
// fields to grab
    
$fields = array(
        
'DateTime''Make''Model'
        
'ShutterSpeedValue''ApertureValue'
        
'ExifImageWidth''ExifImageLength'
    
);
    
    
// if no image data returned
    
if($exif === false)
        echo(
'No Exif Data Found.');
        
    else
    {
        
        foreach(
$fields as $field)
            echo(
'<b>'$field .':</b> '$exif[$field] .'<br />');
        
    }
    
?>

Comments on this article:


I love feedback and comments, be the first!

Add Comment:


Make a Comment

*Nb, all comments are moderated to prevent spam or inappropriate content.








netforge logo
netforge provides high quality and friendly website design services to business. We're Australian based and reliable... (find out more).