From 1375ed6aea765f16ff70606187d1458ee85ea6d9 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 28 Oct 2015 20:01: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 | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/photo/photo_driver.php') diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index 32b9bd302..d439e9877 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -542,6 +542,7 @@ function guess_image_type($filename, $headers = '') { } } +/* if(is_null($type)) { $ext = pathinfo($filename, PATHINFO_EXTENSION); $ph = photo_factory(''); @@ -551,6 +552,13 @@ 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; -- cgit v1.2.3 From a5f1fa3168d487655d4743f7680d36d80053b34f Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 28 Oct 2015 21:52:15 +0100 Subject: re-enable pathinfo() check and try with getimagesize() if we have not got a result --- include/photo/photo_driver.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include/photo/photo_driver.php') diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index d439e9877..810e0cdc7 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -542,23 +542,22 @@ function guess_image_type($filename, $headers = '') { } } -/* if(is_null($type)) { $ext = pathinfo($filename, PATHINFO_EXTENSION); $ph = photo_factory(''); $types = $ph->supportedTypes(); - $type = "image/jpeg"; foreach ($types as $m=>$e){ 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; -- cgit v1.2.3 From 0a9b2b6b15bcf3f3b2fe604defd0cd99934f992b Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 29 Oct 2015 11:29:11 +0100 Subject: possibly better fox for profil photo image type issue --- include/photo/photo_driver.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'include/photo/photo_driver.php') diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index 810e0cdc7..f9b6e5ea8 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -593,11 +593,6 @@ function import_xchan_photo($photo,$xchan,$thing = false) { if($photo) { $filename = basename($photo); - $type = guess_image_type($photo); - - if(! $type) - $type = 'image/jpeg'; - $result = z_fetch_url($photo,true); @@ -614,6 +609,7 @@ function import_xchan_photo($photo,$xchan,$thing = false) { } } } + $type = guess_image_type($photo, $result['header']); } } else { -- cgit v1.2.3 From d66be62516c1297135d707f0d565e100651529d5 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 29 Oct 2015 11:34:30 +0100 Subject: move it up --- include/photo/photo_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/photo/photo_driver.php') diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index f9b6e5ea8..e980a96e1 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -598,6 +598,7 @@ function import_xchan_photo($photo,$xchan,$thing = false) { if($result['success']) { $img_str = $result['body']; + $type = guess_image_type($photo, $result['header']); $h = explode("\n",$result['header']); if($h) { @@ -609,7 +610,6 @@ function import_xchan_photo($photo,$xchan,$thing = false) { } } } - $type = guess_image_type($photo, $result['header']); } } else { -- cgit v1.2.3 From 7ce3ebc46d3c0b007dd846adaa4097c69d26d0eb Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 1 Nov 2015 21:04:55 +0100 Subject: make sure we only have one profile photo for a cloned channel --- include/photo/photo_driver.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include/photo/photo_driver.php') diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index e980a96e1..285cbc8fb 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -734,6 +734,11 @@ function import_channel_photo($photo,$type,$aid,$uid) { $photo_failure = true; } - return(($photo_failure)? false : true); + //return(($photo_failure)? false : true); + + if($photo_failure) + return false; + else + return $hash; } -- cgit v1.2.3