aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/exif.php27
1 files changed, 21 insertions, 6 deletions
diff --git a/lib/exif.php b/lib/exif.php
index 1bebb5fdc..5382fbc9f 100644
--- a/lib/exif.php
+++ b/lib/exif.php
@@ -1,27 +1,39 @@
<?php
include_once dirname(__FILE__) . "/tidypics.php";
-function td_get_exif($file_guid) {
- $file = new ElggFile($file_guid);
+function td_get_exif($file) {
+ $mime = $file->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), "string", $file->getObjectOwnerGUID(), 2);
+ create_metadata($file->getGUID(), "tp_exif", serialize($exif), "string", $file->getObjectOwnerGUID(), ACCESS_PUBLIC);
}
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
- td_get_exif($file_guid);
+ $file = new ElggFile($file_guid);
+ td_get_exif($file);
+ unset($file);
$metadata_exif = get_metadata_byname($file_guid, "tp_exif");
}
if($metadata_exif) {
+
$exif = unserialize($metadata_exif["value"]);
//got the code snippet below from http://www.zenphoto.org/support/topic.php?id=17
//convert the raw values to understandible values
$Fnumber = explode("/", $exif['FNumber']);
- $Fnumber = $Fnumber[0] / $Fnumber[1];
+
+ if ($Fnumber[1] != 0)
+ $Fnumber = $Fnumber[0] / $Fnumber[1];
+ else
+ $Fnumber = 0;
+
if(!$Fnumber) {
$Fnumber = "N/A";
} else {
@@ -29,7 +41,10 @@ function tp_exif_formatted($file_guid) {
}
$Focal = explode("/", $exif['FocalLength']);
- $Focal = $Focal[0] / $Focal[1];
+ if ($Focal[1] != 0)
+ $Focal = $Focal[0] / $Focal[1];
+ else
+ $Focal = 0;
if(!$Focal || round($Focal) == "0") $Focal = 0;
if(round($Focal) == 0) {
$Focal = "N/A";