Created
October 9, 2012 19:14
-
-
Save bobmagicii/3860805 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| protected function ReturnFileProperties($File) | |
| { | |
| if($Fileprops = new Imagick($File)) | |
| { | |
| $FileProps = array(); | |
| $FileProps['MimeType'] = "IMAGE/".$Fileprops->getImageFormat(); | |
| $FileProps['FileSize'] = $Fileprops->getImageLength(); | |
| $FileProps['FileName'] = basename($File); | |
| $FileProps['Width'] = $Fileprops->getImageWidth(); | |
| $FileProps['Height'] = $Fileprops->getImageHeight(); | |
| $FileProps['CreationDate'] = date("c",strtotime($Fileprops->getImageProperties("exif:DateTimeOriginal", TRUE)['exif:DateTimeOriginal']))."Z"; | |
| return($FileProps); | |
| } | |
| else | |
| return(false); | |
| } | |
| */ | |
| protected function ReturnFileProperties($File) { | |
| if(($Image = new Imagick($File))) { | |
| // it is quite possible exif data you wanted will be missing. here is | |
| // a list of shit we want with reasonable defaults. | |
| $Exif = $Image->getImageProperties('exif:*',true); | |
| $ExifKeys = array( | |
| 'exif:DateTimeOriginal' => date('Y-m-d') | |
| ); | |
| foreach($ExifKeys as $Key => $Default) { | |
| if(!array_key_exists($Key,$Exif)) | |
| $Exif[$Key] = $Default; | |
| } | |
| // generaete your associative array of data. | |
| $Properties = array( | |
| 'MimeType' => $Image->getImageMimeType(), | |
| 'FileSize' => $Image->getImageLength(), | |
| 'FileName' => basename($File), | |
| 'Width' => $Image->getImageWidth(), | |
| 'Height' => $Image->getImageHeight(), | |
| 'CreationDate' => date('c',strtotime($Exif['exif:DateTimeOriginal'])).'Z' | |
| ); | |
| return $Properties; | |
| } else { | |
| return false; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment