ImageScaleByAspectRatioV2 node add background_color option

This commit is contained in:
chflame163
2024-07-11 20:34:02 +08:00
parent aed1162b28
commit b28c95baae
7 changed files with 22 additions and 18 deletions
+5 -4
View File
@@ -80,7 +80,8 @@ When this error has occurred, please check the network environment.
## Update
<font size="4">**If the dependency package error after updating, please reinstall the relevant dependency packages. </font><br />
* [LUT Apply](#LUT) Add the street parameter.
* [ImageScaleByAspectRatioV2](#ImageScaleByAspectRatioV2) node add the "background_color" option.
* [LUT Apply](#LUT) Add the "strength" option.
* Commit [AutoAdjustV2](#AutoAdjustV2) node, add optional mask input and support for multiple automatic color adjustment modes.
* Due to the upcoming discontinuation of gemini-pro vision services, [PromptTagger](#PromptTagger) and [PromptEmbellish](#PromptEmbellish) have added the "gemini-1.5-flash" API to continue using it.
* [Ultra](#Ultra) nodes added the option to run ```VitMatte``` on the CUDA device, resulting in a 5-fold increase in running speed.
@@ -688,7 +689,7 @@ Node options:
The following changes have been made based on ImageScaleByAspectRatio:
* scale_to_side: Allow scaling by specified dimensions for long, short, width, height, or total pixels.
* scale_to_length: The numerical value here serves as the length of the specified edge or the total pixels (kilo pixels) for scale_to_side.
* background_color<sup>4</sup>: The color of the background.
### <a id="table1">QWenImage2Prompt</a>
@@ -740,7 +741,7 @@ Node options:
* shift_x: Horizontal distance of shift.
* shift_y: Vertical distance of shift.
* cyclic: Is the part of displacement that is out of bounds cyclic.
* background_color: Background color. if cyclic is set to False, the setting here will be used as the background color.
* background_color<sup>4</sup>: Background color. if cyclic is set to False, the setting here will be used as the background color.
* border_mask_width: Border mask width.
* border_mask_blur: Border mask blur.
* [note](#notes)
@@ -990,7 +991,7 @@ Node options:
* width: Width of the image. If there is a size_as input, this setting will be ignored.
* height: Height of the image. If there is a size_as input, this setting will be ignored.
* text_color: The color of text.
* background_color: The color of background.
* background_color<sup>4</sup>: The color of background.
<sup>*</sup>Only limited to input image and mask. forcing the integration of other types of inputs will result in node errors.
+5 -4
View File
@@ -80,7 +80,8 @@ git clone https://github.com/chflame163/ComfyUI_LayerStyle.git
## 更新说明
<font size="4">**如果本插件更新后出现依赖包错误,请重新安装相关依赖包。
* [LUT Apply](#LUT) 节点增加strenght参数。
* [ImageScaleByAspectRatioV2](#ImageScaleByAspectRatioV2) 节点增加background_color选项。
* [LUT Apply](#LUT) 节点增加strenght选项。
* 添加 [AutoAdjustV2](#AutoAdjustV2) 节点,增加可选遮罩输入,增加多种自动调色模式支持。
* 由于gemini-pro-vision即将停止服务, [PromptTagger](#PromptTagger) 和 [PromptEmbellish](#PromptEmbellish) 添加"gemini-1.5-flash" API以继续使用。
* [Ultra](#Ultra) 节点增加```VitMatte```方法在CUDA设备运行选项,运行速度提升5倍。
@@ -678,7 +679,7 @@ ImageScaleByAspectRatio的V2升级版
在ImageScaleByAspectRatio基础上做了如下改变:
* scale_to_side: 允许按长边、短边、宽度、高度或总像素指定尺寸缩放。
* scale_to_length: 这里的数值作为scale_to_side指定边的长度, 或者总像素数量(kilo pixels)。
* background_color<sup>4</sup>: 背景色。
### <a id="table1">QWenImage2Prompt</a>
@@ -729,7 +730,7 @@ ImageScaleByAspectRatio的V2升级版
* shift_x: 位移的横向距离。
* shift_y: 位移的纵向距离。
* cyclic: 位移出界的部分是否循环。
* background_color: 背景颜色。如果cyclic设置为False,将使用这里的设置作为背景颜色。
* background_color<sup>4</sup>: 背景颜色。如果cyclic设置为False,将使用这里的设置作为背景颜色。
* border_mask_width: 接缝遮罩宽度。
* border_mask_blur: 接缝遮罩模糊。
* [节点注解](#节点注解)
@@ -981,7 +982,7 @@ GradientImage的V2升级版。
* width: 画面的宽度。如果有size_as输入,此设置将被忽略。
* height: 画面的高度。如果有size_as输入,此设置将被忽略。
* text_color: 文字颜色。
* background_color: 背景颜色。
* background_color<sup>4</sup>: 背景颜色。
<sup>*</sup>仅限输入image和mask, 如果强制接入其他类型输入,将导致节点错误。
Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 76 KiB

+2 -2
View File
@@ -65,8 +65,8 @@ class CropByMask:
else:
(x, y, width, height) = mask_area(_mask)
width = num_round_to_multiple(width, 8)
height = num_round_to_multiple(height, 8)
width = num_round_up_to_multiple(width, 8)
height = num_round_up_to_multiple(height, 8)
log(f"{NODE_NAME}: Box detected. x={x},y={y},width={width},height={height}")
canvas_width, canvas_height = tensor2pil(torch.unsqueeze(image[0], 0)).convert('RGB').size
x1 = x - left_reserve if x - left_reserve > 0 else 0
+1 -1
View File
@@ -10,7 +10,7 @@ class CropByMaskV2:
@classmethod
def INPUT_TYPES(self):
detect_mode = ['mask_area', 'min_bounding_rect', 'max_inscribed_rect']
multiple_list = ['8', '16', '32', '64', 'None']
multiple_list = ['8', '16', '32', '64', '128', '256', '512', 'None']
return {
"required": {
"image": ("IMAGE", ), #
+3 -3
View File
@@ -14,7 +14,7 @@ class ImageScaleByAspectRatio:
ratio_list = ['original', 'custom', '1:1', '3:2', '4:3', '16:9', '2:3', '3:4', '9:16']
fit_mode = ['letterbox', 'crop', 'fill']
method_mode = ['lanczos', 'bicubic', 'hamming', 'bilinear', 'box', 'nearest']
multiple_list = ['8', '16', '32', '64', 'None']
multiple_list = ['8', '16', '32', '64', '128', '256', '512', 'None']
return {
"required": {
@@ -107,8 +107,8 @@ class ImageScaleByAspectRatio:
if round_to_multiple != 'None':
multiple = int(round_to_multiple)
target_width = num_round_to_multiple(target_width, multiple)
target_height = num_round_to_multiple(target_height, multiple)
target_width = num_round_up_to_multiple(target_width, multiple)
target_height = num_round_up_to_multiple(target_height, multiple)
_mask = Image.new('L', size=(target_width, target_height), color='black')
_image = Image.new('RGB', size=(target_width, target_height), color='black')
+6 -4
View File
@@ -14,7 +14,7 @@ class ImageScaleByAspectRatioV2:
ratio_list = ['original', 'custom', '1:1', '3:2', '4:3', '16:9', '2:3', '3:4', '9:16']
fit_mode = ['letterbox', 'crop', 'fill']
method_mode = ['lanczos', 'bicubic', 'hamming', 'bilinear', 'box', 'nearest']
multiple_list = ['8', '16', '32', '64', 'None']
multiple_list = ['8', '16', '32', '64', '128', '256', '512', 'None']
scale_to_list = ['None', 'longest', 'shortest', 'width', 'height', 'total_pixel(kilo pixel)']
return {
"required": {
@@ -26,6 +26,7 @@ class ImageScaleByAspectRatioV2:
"round_to_multiple": (multiple_list,),
"scale_to_side": (scale_to_list,), # 是否按长边缩放
"scale_to_length": ("INT", {"default": 1024, "min": 4, "max": 999999, "step": 1}),
"background_color": ("STRING", {"default": "#000000"}), # 背景颜色
},
"optional": {
"image": ("IMAGE",), #
@@ -40,6 +41,7 @@ class ImageScaleByAspectRatioV2:
def image_scale_by_aspect_ratio(self, aspect_ratio, proportional_width, proportional_height,
fit, method, round_to_multiple, scale_to_side, scale_to_length,
background_color,
image=None, mask = None,
):
orig_images = []
@@ -128,8 +130,8 @@ class ImageScaleByAspectRatioV2:
if round_to_multiple != 'None':
multiple = int(round_to_multiple)
target_width = num_round_to_multiple(target_width, multiple)
target_height = num_round_to_multiple(target_height, multiple)
target_width = num_round_up_to_multiple(target_width, multiple)
target_height = num_round_up_to_multiple(target_height, multiple)
_mask = Image.new('L', size=(target_width, target_height), color='black')
_image = Image.new('RGB', size=(target_width, target_height), color='black')
@@ -149,7 +151,7 @@ class ImageScaleByAspectRatioV2:
if len(orig_images) > 0:
for i in orig_images:
_image = tensor2pil(i).convert('RGB')
_image = fit_resize_image(_image, target_width, target_height, fit, resize_sampler)
_image = fit_resize_image(_image, target_width, target_height, fit, resize_sampler, background_color)
ret_images.append(pil2tensor(_image))
if len(orig_masks) > 0:
for m in orig_masks: