From 128d1f7aa8a11e0394913a10daef56cd4be450b1 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 13 Mar 2018 22:47:11 -0700 Subject: somewhere along the line the output of exif_read_data() changed and it no longer provides populated sections. Adjust for the new format and allow for the old because I cannot find documentation of this change anywhere. This affects photo rotation and the photo map feature. --- include/photo/photo_driver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/photo') diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index 6af753195..00284a288 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -289,12 +289,12 @@ abstract class photo_driver { return false; } - $ort = $exif['IFD0']['Orientation']; + $ort = ((array_key_exists('IFD0',$exif)) ? $exif['IFD0']['Orientation'] : $exif['Orientation']); if(! $ort) { return false; } - + switch($ort) { case 1: // nothing break; -- cgit v1.2.3 From 0905018d3b3b02def2b0e69e9bc4c4ef2b2b86aa Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 14 Mar 2018 14:51:33 -0700 Subject: use original exif_read_data() parameters which were lost in a regression; unset automatic nsfw category generated for Mastodon content warning posts, as people use CW as a spoiler mechanism 99% of the time and flagging inappropriate content 1% of the time. --- include/photo/photo_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/photo') diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index 00284a288..22d2b776d 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -273,7 +273,7 @@ abstract class photo_driver { } if($f) { - return @exif_read_data($f); + return @exif_read_data($f,null,true); } return false; -- cgit v1.2.3 From 55dc6fbc1cae70e4f2b207c517c8c9155fda9662 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 22 Apr 2018 18:12:16 -0700 Subject: imagemagick preserves exif when scaling. GD does not. We do not want to preserve exif on thumbnails which we have rotated, as a browser reading the exif information could rotate them yet again. This checkin adds an abstract function to the generic photo driver which makes the behaviour consistent by stripping EXIF from imagick processed images. However, we will attempt to preserve any ICC colour profiles. See http://php.net/manual/en/imagick.stripimage.php --- include/photo/photo_driver.php | 1 + include/photo/photo_gd.php | 5 +++++ include/photo/photo_imagick.php | 13 +++++++++++++ 3 files changed, 19 insertions(+) (limited to 'include/photo') diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index 22d2b776d..2e2f5a758 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -75,6 +75,7 @@ abstract class photo_driver { abstract function imageString(); + abstract function clearexif(); public function __construct($data, $type='') { $this->types = $this->supportedTypes(); diff --git a/include/photo/photo_gd.php b/include/photo/photo_gd.php index 24bdc204f..e98ac2827 100644 --- a/include/photo/photo_gd.php +++ b/include/photo/photo_gd.php @@ -35,6 +35,11 @@ class photo_gd extends photo_driver { } + public function clearexif() { + return; + } + + public function destroy() { if($this->is_valid()) { imagedestroy($this->image); diff --git a/include/photo/photo_imagick.php b/include/photo/photo_imagick.php index 32bb61342..89577e71e 100644 --- a/include/photo/photo_imagick.php +++ b/include/photo/photo_imagick.php @@ -96,6 +96,19 @@ class photo_imagick extends photo_driver { } + public function clearexif() { + + $profiles = $this->image->getImageProfiles("icc", true); + + $this->image->stripImage(); + + if(!empty($profiles)) { + $this->image->profileImage("icc", $profiles['icc']); + } + } + + + public function getImage() { if(!$this->is_valid()) return FALSE; -- cgit v1.2.3