From 0b2312452d85c9faa266eb01e2c554bf46ff01d7 Mon Sep 17 00:00:00 2001 From: Laighlinne Date: Tue, 27 Feb 2018 05:32:01 +0900 Subject: [PATCH 1/5] thumbnail image doesn't have alpha value --- classes/file/FileHandler.class.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/classes/file/FileHandler.class.php b/classes/file/FileHandler.class.php index 6ffe9b8b67..2026d3d0f0 100644 --- a/classes/file/FileHandler.class.php +++ b/classes/file/FileHandler.class.php @@ -841,7 +841,24 @@ function createImageFile($source_file, $target_file, $resize_width = 0, $resize_ return FALSE; } - imagefilledrectangle($thumb, 0, 0, $resize_width - 1, $resize_height - 1, imagecolorallocate($thumb, 255, 255, 255)); + if(function_exists('imagecolorallocatealpha') && $target_type == 'png') + { + imagefill($thumb, 0, 0, imagecolorallocatealpha($thumb, 0, 0, 0, 127)); + + if(function_exists('imagesavealpha')) + { + imagesavealpha($thumb, TRUE); + } + + if(function_exists('imagealphablending')) + { + imagealphablending($thumb, true); + } + } + else + { + imagefilledrectangle($thumb, 0, 0, $resize_width - 1, $resize_height - 1, imagecolorallocate($thumb, 255, 255, 255)); + } // create temporary image having original type $source = NULL; From f4e1d0fb8b273b6e170b7af2aaea84fdb2dbb212 Mon Sep 17 00:00:00 2001 From: Laighlinne Date: Tue, 27 Feb 2018 06:32:13 +0900 Subject: [PATCH 2/5] Update FileHandler.class.php --- classes/file/FileHandler.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/file/FileHandler.class.php b/classes/file/FileHandler.class.php index 2026d3d0f0..0634ac9efa 100644 --- a/classes/file/FileHandler.class.php +++ b/classes/file/FileHandler.class.php @@ -852,7 +852,7 @@ function createImageFile($source_file, $target_file, $resize_width = 0, $resize_ if(function_exists('imagealphablending')) { - imagealphablending($thumb, true); + imagealphablending($thumb, TRUE); } } else From 41c669c5be3599915f4408606daa435c124c0696 Mon Sep 17 00:00:00 2001 From: Laighlinne Date: Tue, 27 Feb 2018 05:41:04 +0900 Subject: [PATCH 3/5] added set background transparent thumbnail option. --- classes/file/FileHandler.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/classes/file/FileHandler.class.php b/classes/file/FileHandler.class.php index 0634ac9efa..e7ce6cd45a 100644 --- a/classes/file/FileHandler.class.php +++ b/classes/file/FileHandler.class.php @@ -751,9 +751,10 @@ function checkMemoryLoadImage(&$imageInfo) * @param int $resize_height Height to resize * @param string $target_type If $target_type is set (gif, jpg, png, bmp), result image will be saved as target type * @param string $thumbnail_type Thumbnail type(crop, ratio) + * @param bool $thumbnail_transparent If $target_type is png, set background set transparent color * @return bool TRUE: success, FALSE: failed */ - function createImageFile($source_file, $target_file, $resize_width = 0, $resize_height = 0, $target_type = '', $thumbnail_type = 'crop') + function createImageFile($source_file, $target_file, $resize_width = 0, $resize_height = 0, $target_type = '', $thumbnail_type = 'crop', $thumbnail_transparent = FALSE) { // check params if (($source_file = self::exists($source_file)) === FALSE) @@ -841,7 +842,7 @@ function createImageFile($source_file, $target_file, $resize_width = 0, $resize_ return FALSE; } - if(function_exists('imagecolorallocatealpha') && $target_type == 'png') + if(function_exists('imagecolorallocatealpha') && $target_type == 'png' && $thumbnail_transparent) { imagefill($thumb, 0, 0, imagecolorallocatealpha($thumb, 0, 0, 0, 127)); From afd13d2ab1dec5e492183180db33c558fceab91c Mon Sep 17 00:00:00 2001 From: LalafellSleep Date: Mon, 19 Mar 2018 20:56:18 +0900 Subject: [PATCH 4/5] Adding Profile image background transparent for UX (from 41c669c) --- modules/member/lang/lang.xml | 5 +++++ modules/member/member.admin.controller.php | 1 + modules/member/member.controller.php | 7 ++++++- modules/member/tpl/signup_config.html | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/member/lang/lang.xml b/modules/member/lang/lang.xml index f1572a0c77..f28617b135 100644 --- a/modules/member/lang/lang.xml +++ b/modules/member/lang/lang.xml @@ -2806,4 +2806,9 @@ + + + + + diff --git a/modules/member/member.admin.controller.php b/modules/member/member.admin.controller.php index 45b9b5099b..2254d2b393 100644 --- a/modules/member/member.admin.controller.php +++ b/modules/member/member.admin.controller.php @@ -292,6 +292,7 @@ public function procMemberAdminInsertSignupConfig() $signupItem->max_width = $all_args->{$key.'_max_width'}; $signupItem->max_height = $all_args->{$key.'_max_height'}; $signupItem->max_filesize = $all_args->{$key.'_max_filesize'}; + $signupItem->allow_transparent_thumbnail = $all_args->{$key.'_transparent_thumbnail'}; } // set extends form diff --git a/modules/member/member.controller.php b/modules/member/member.controller.php index 4bf10efc00..b8a3a30914 100644 --- a/modules/member/member.controller.php +++ b/modules/member/member.controller.php @@ -766,6 +766,11 @@ function insertProfileImage($member_srl, $target_file) $max_width = $config->profile_image_max_width; $max_height = $config->profile_image_max_height; $max_filesize = $config->profile_image_max_filesize; + foreach($config->signupForm as $val) + { + if($val->name == "profile_image") + $allow_transparent = $val->allow_transparent_thumbnail == 'Y'; + } Context::loadLang(_XE_PATH_ . 'modules/file/lang'); @@ -789,7 +794,7 @@ function insertProfileImage($member_srl, $target_file) if(($width > $max_width || $height > $max_height ) && $type != 1) { $temp_filename = sprintf('files/cache/tmp/profile_image_%d.%s', $member_srl, $ext); - FileHandler::createImageFile($target_file, $temp_filename, $max_width, $max_height, $ext); + FileHandler::createImageFile($target_file, $temp_filename, $max_width, $max_height, $ext, 'crop', $allow_transparent); // 파일 용량 제한 FileHandler::clearStatCache($temp_filename); diff --git a/modules/member/tpl/signup_config.html b/modules/member/tpl/signup_config.html index 453b38add5..f5e13ddd82 100644 --- a/modules/member/tpl/signup_config.html +++ b/modules/member/tpl/signup_config.html @@ -132,6 +132,7 @@ +