Yii 1.1: exifreader

An EXIF data reader for JPEG and TIFF images.
3 followers

This extentsion allows you ti read EXIF data (including thumbnails) from your JPEG and TIFF images.

Resources

Documentation

Requirements

  • Yii 1.0 or above

Installation

  • Extract the release file under protected/extensions

Usage

See the following code example:

Yii::import('application.extensions.exifreader.CExifReader');

or add to your config:

'components'=>array(
    'CExifReader' => array(
        'class'=>'ext.exifreader.CExifReader',
    ),
),

and then in your Controller or View write:

$exifReader = new CExifReader;
// or $exifReader = Yii::app()->CExifReader;
 
$exifReader->file = PATH_TO_YOUR_FILE;
$data = $exifReader->getExifData(array(
    // first parameter is tag which we want to get
    // second is which section from it we want to ignore
    array('FILE', array('SectionsFound')),
    'COMPUTED',
    'THUMBNAIL',
    array('IFD0', array('UndefinedTag:0xC4A5')),
    array('EXIF', array('MakerNote')),
));
$thumbnail = $exifReader->getExifThumbnail();

and then you can display result for data:

if (is_array($data) && !empty($data)) {
 
    echo '<table>';
    foreach ($data as $item) {
        if (!empty($item)) {
            foreach ($item as $key => $value) {
                echo '<tr><td><strong>'.$key.'</strong></td><td>'.$value.'</td></tr>';
            }
        }
    }
    echo '</table>';
 
}

and for thumbnail:

echo '<img width="'.$thumbnail['width'].'" height="'.$thumbnail['height'].'" src="data:'
.image_type_to_mime_type($thumbnail['type']).';base64,'.base64_encode($thumbnail['thumb']).'">';

enjoy!

Change Log

January 29, 2010

  • Initial beta release.

Be the first person to leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: New BSD License
  • Developed by: ujovlado
  • Category: Others
  • Votes: +2
  • Downloaded: 523 times
  • Created on: Jan 29, 2010
  • Last updated: Jan 31, 2010