aboutsummaryrefslogtreecommitdiff
path: root/lib/exif.php
diff options
context:
space:
mode:
authorGreg Froese <greg.froese@gmail.com>2009-05-20 05:01:21 +0000
committerGreg Froese <greg.froese@gmail.com>2009-05-20 05:01:21 +0000
commit12a27fa3b501cf08091cd063dd3208a17e0f624a (patch)
treed993e49523465f2e2d8e856785072526a72cff30 /lib/exif.php
parent63b91d8aee8e40497d865591d16ee1716e0c9c15 (diff)
downloadelgg-12a27fa3b501cf08091cd063dd3208a17e0f624a.tar.gz
elgg-12a27fa3b501cf08091cd063dd3208a17e0f624a.tar.bz2
added exif support
Diffstat (limited to 'lib/exif.php')
-rw-r--r--lib/exif.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/exif.php b/lib/exif.php
new file mode 100644
index 000000000..1b6c2cbd2
--- /dev/null
+++ b/lib/exif.php
@@ -0,0 +1,35 @@
+<?php
+include_once dirname(__FILE__) . "/tidypics.php";
+
+function td_get_exif(Elggfile $file) {
+ $my_file = str_replace("image", "", tp_get_img_dir()) . $file->getFilename();
+ $exif = exif_read_data($my_file);
+ create_metadata($file->getGUID(), "tp_exif", serialize($exif), "string", $file->getObjectOwnerGUID(), 2);
+}
+
+function tp_exif_formatted($file_guid) {
+ $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];
+ $Focal = explode("/", $exif['FocalLength']);
+ $Focal = $Focal[0] / $Focal[1];
+
+ //prepare the text for return
+ $exif_text = "Model: ".$exif['Model']."<br>";
+ $exif_text .= "Shutter: ".$exif['ExposureTime']."<br>";
+ $exif_text .= "Aperture: f/".$Fnumber."<br>";
+ $exif_text .= "ISO Speed: ".$exif['ISOSpeedRatings']."<br>";
+ $exif_text .= "Focal Length: ".round($Focal)."mm<br>";
+ $exif_text .= "Captured: ". $exif['DateTime'];
+
+ return "<tr><td>$exif_text</td></tr>";
+ } else {
+ return false;
+ }
+}
+?> \ No newline at end of file