summaryrefslogtreecommitdiffstats
path: root/application/libraries/Exif.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/libraries/Exif.php')
-rw-r--r--application/libraries/Exif.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/application/libraries/Exif.php b/application/libraries/Exif.php
new file mode 100644
index 000000000..27dd11a65
--- /dev/null
+++ b/application/libraries/Exif.php
@@ -0,0 +1,37 @@
+<?php
+/*
+ * Copyright 2014-2015 Florian "Bluewind" Pritz <bluewind@server-speed.net>
+ *
+ * Licensed under AGPLv3
+ * (see COPYING for full license text)
+ *
+ */
+
+namespace libraries;
+
+class Exif {
+ static public function get_exif($file)
+ {
+ // TODO: support more types (identify or exiftool? might be slow :( )
+ try {
+ $type = getimagesize($file)[2];
+ } catch (\ErrorException $e) {
+ return false;
+ }
+ switch ($type) {
+ case IMAGETYPE_JPEG:
+ getimagesize($file, $info);
+ if (isset($info["APP1"]) && strpos($info["APP1"], "http://ns.adobe.com/xap/1.0/") === 0) {
+ // ignore XMP data which makes exif_read_data throw a warning
+ // http://stackoverflow.com/a/8864064
+ return false;
+ }
+ return @exif_read_data($file);
+ break;
+ default:
+ }
+
+ return false;
+ }
+
+}