diff --git a/classes/file/FileHandler.class.php b/classes/file/FileHandler.class.php index 6ffe9b8b67..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,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' && $thumbnail_transparent) + { + 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; 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..9d85368e3c 100644 --- a/modules/member/tpl/signup_config.html +++ b/modules/member/tpl/signup_config.html @@ -132,6 +132,7 @@ +