diff options
author | Cash Costello <cash.costello@gmail.com> | 2012-07-14 14:42:37 -0400 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2012-07-14 14:42:37 -0400 |
commit | 0eec78495e5f63a80c2b04fcb87bda1ccb2b6648 (patch) | |
tree | 42b2bb3b35e8d6ba2924f0aabe42f218beea6bca /lib/exif.php | |
parent | 65548983c054a48fe0adb94c327847a7101db390 (diff) | |
download | elgg-0eec78495e5f63a80c2b04fcb87bda1ccb2b6648.tar.gz elgg-0eec78495e5f63a80c2b04fcb87bda1ccb2b6648.tar.bz2 |
added exif back
Diffstat (limited to 'lib/exif.php')
-rw-r--r-- | lib/exif.php | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/lib/exif.php b/lib/exif.php index 43a640336..8ca0dde0c 100644 --- a/lib/exif.php +++ b/lib/exif.php @@ -8,47 +8,48 @@ /** * Pull EXIF data from image file * - * @param TidypicsImage $file + * @param TidypicsImage $image */ -function td_get_exif($file) { +function td_get_exif($image) { // catch for those who don't have exif module loaded if (!is_callable('exif_read_data')) { return; } - $mime = $file->mimetype; + $mime = $image->mimetype; if ($mime != 'image/jpeg' && $mime != 'image/pjpeg') { return; } - $filename = $file->getFilenameOnFilestore(); - $exif = exif_read_data($filename); - create_metadata($file->getGUID(), "tp_exif", serialize($exif), "text", $file->getOwnerGUID(), ACCESS_PUBLIC); + $filename = $image->getFilenameOnFilestore(); + $exif = exif_read_data($filename, 'IFD0,EXIF', true); + if (is_array($exif)) { + $data = array_merge($exif['IFD0'], $exif['EXIF']); + foreach ($data as $key => $value) { + if (is_string($value)) { + // there are sometimes unicode characters that cause problems with serialize + $data[$key] = preg_replace( '/[^[:print:]]/', '', $value); + } + } + $image->tp_exif = serialize($data); + } } /** * Grab array of EXIF data for display * - * @param int $file_guid GUID of TidypicsImage + * @param TidypicsImage $image * @return array|false */ -function tp_exif_formatted($file_guid) { - - $metadata_exif = get_metadata_byname($file_guid, "tp_exif"); - if (!$metadata_exif) { - // //try to load it from the file if its not in the database - $file = new ElggFile($file_guid); - td_get_exif($file); - unset($file); - $metadata_exif = get_metadata_byname($file_guid, "tp_exif"); - } +function tp_exif_formatted($image) { - if (!$metadata_exif) { + $exif = $image->tp_exif; + if (!$exif) { return false; } - $exif = unserialize($metadata_exif["value"]); + $exif = unserialize($exif); $model = $exif['Model']; if (!$model) { |