aboutsummaryrefslogtreecommitdiff
path: root/lib/exif.php
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2009-06-07 01:28:16 +0000
committerCash Costello <cash.costello@gmail.com>2009-06-07 01:28:16 +0000
commitb2ef95042c8335e75657b29f6dabbec4d0266426 (patch)
treee6c867698a4db59993d79b522651eaabfcd001fa /lib/exif.php
parent23b24f6adb289b6a7c1fe475c4068f2f99130ce7 (diff)
downloadelgg-b2ef95042c8335e75657b29f6dabbec4d0266426.tar.gz
elgg-b2ef95042c8335e75657b29f6dabbec4d0266426.tar.bz2
improved exif code - catching pngs, gifs, etc
The display code should be moved to a view to keep it separate from the controller code
Diffstat (limited to 'lib/exif.php')
-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";