summaryrefslogtreecommitdiffstats
path: root/application/libraries/Exif.php
blob: 27dd11a656b3787e603ac8472f8f96867b591cf4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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;
	}

}