This extentsion allows you ti read EXIF data (including thumbnails) from your JPEG and TIFF images.
protected/extensionsSee 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!
Be the first person to leave a comment
Please login to leave your comment.