From f1a3b281d4573e12f7a81efa03fb1db73ba34e27 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 28 Oct 2015 19:59:50 +0100 Subject: pathinfo() does not work in this case. getimagesize() seems more reliabel. this fixes transparent png avatars having a black background. --- include/photo/photo_driver.php | 10 +++++++++- include/photo/photo_gd.php | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index 5d61556ab..db98f7085 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -541,7 +541,7 @@ function guess_image_type($filename, $headers = '') { // we aren't using imagick can find it } } - +/* if(is_null($type)) { $ext = pathinfo($filename, PATHINFO_EXTENSION); $ph = photo_factory(''); @@ -551,6 +551,14 @@ function guess_image_type($filename, $headers = '') { if ($ext==$e) $type = $m; } } +*/ + if(is_null($type)) { + $size = getimagesize($filename); + $ph = photo_factory(''); + $types = $ph->supportedTypes(); + $type = ((array_key_exists($size['mime'], $types)) ? $size['mime'] : 'image/jpeg'); + } + } logger('Photo: guess_image_type: type='.$type, LOGGER_DEBUG); return $type; diff --git a/include/photo/photo_gd.php b/include/photo/photo_gd.php index fa1f700e9..2ac7287e4 100644 --- a/include/photo/photo_gd.php +++ b/include/photo/photo_gd.php @@ -137,4 +137,4 @@ class photo_gd extends photo_driver { return $string; } -} \ No newline at end of file +} -- cgit v1.2.3