diff options
author | Florian Pritz <bluewind@xinu.at> | 2014-11-08 18:23:38 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2014-11-08 18:24:25 +0100 |
commit | a6655941189e692c4ff06aa41a65e4ac7f0e82fd (patch) | |
tree | 478d55f870a853692ddae57677dc0cb614b11a10 /application/libraries | |
parent | 476cfd42a72bcd3fb3ee0063d052163447c477f8 (diff) |
Fix handling of images with XMP instead of EXIF data
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/libraries')
-rw-r--r-- | application/libraries/Image.php | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/application/libraries/Image.php b/application/libraries/Image.php index 6d6c9e563..a50209872 100644 --- a/application/libraries/Image.php +++ b/application/libraries/Image.php @@ -41,13 +41,26 @@ class Image { $this->fix_alpha(); $this->source_type = getimagesize($file)[2]; + $this->exif = self::get_exif($file); + } - switch ($this->source_type) { + static private function get_exif($file) + { + $type = getimagesize($file)[2]; + switch ($type) { case IMAGETYPE_JPEG: - $this->exif = exif_read_data($file); + getimagesize($file, $info); + if (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; } /** @@ -165,18 +178,11 @@ class Image { static public function get_exif_orientation($file) { - $type = getimagesize($file)[2]; - switch ($type) { - case IMAGETYPE_JPEG: - $exif = exif_read_data($file); - if (isset($exif["Orientation"])) { - return $exif["Orientation"]; - } - return 0; - break; - default: - return 0; + $exif = self::get_exif($file); + if (isset($exif["Orientation"])) { + return $exif["Orientation"]; } + return 0; } /** |