fix LayerImageTransform and LayerMaskTransfrom rotate anchorpoint to image center
This commit is contained in:
+1
-1
@@ -607,7 +607,7 @@ def image_rotate_extend_with_alpha(image:Image, angle:float, alpha:Image=None, m
|
||||
ret_image = RGB2RGBA(_image, _alpha)
|
||||
else:
|
||||
ret_image = _image
|
||||
return (_image, _alpha, ret_image)
|
||||
return (_image, _alpha.convert('L'), ret_image)
|
||||
|
||||
def create_box_gradient(start_color_inhex:str, end_color_inhex:str, width:int, height:int, scale:int=50) -> Image:
|
||||
# scale is percent of border to center for the rectangle
|
||||
|
||||
@@ -21,7 +21,7 @@ class LayerImageTransform:
|
||||
"aspect_ratio": ("FLOAT", {"default": 1, "min": 0.01, "max": 100, "step": 0.01}),
|
||||
"rotate": ("FLOAT", {"default": 0, "min": -999999, "max": 999999, "step": 0.01}),
|
||||
"transform_method": (method_mode,),
|
||||
"anti_aliasing": ("INT", {"default": 0, "min": 0, "max": 16, "step": 1}),
|
||||
"anti_aliasing": ("INT", {"default": 2, "min": 0, "max": 16, "step": 1}),
|
||||
},
|
||||
"optional": {
|
||||
}
|
||||
@@ -72,8 +72,10 @@ class LayerImageTransform:
|
||||
# rotate
|
||||
_image, _mask, _ = image_rotate_extend_with_alpha(_image, rotate, _mask, transform_method, anti_aliasing)
|
||||
# composit layer
|
||||
_image_canvas.paste(_image, (x, y))
|
||||
_mask_canvas.paste(_mask, (x, y))
|
||||
paste_x = (orig_layer_width - _image.width) // 2 + x
|
||||
paste_y = (orig_layer_height - _image.height) // 2 + y
|
||||
_image_canvas.paste(_image, (paste_x, paste_y))
|
||||
_mask_canvas.paste(_mask, (paste_x, paste_y))
|
||||
if tensor2pil(layer_image).mode == 'RGBA':
|
||||
_image_canvas = RGB2RGBA(_image_canvas, _mask_canvas)
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class LayerMaskTransform:
|
||||
"aspect_ratio": ("FLOAT", {"default": 1, "min": 0.01, "max": 100, "step": 0.01}),
|
||||
"rotate": ("FLOAT", {"default": 0, "min": -999999, "max": 999999, "step": 0.01}),
|
||||
"transform_method": (method_mode,),
|
||||
"anti_aliasing": ("INT", {"default": 0, "min": 0, "max": 16, "step": 1}),
|
||||
"anti_aliasing": ("INT", {"default": 2, "min": 0, "max": 16, "step": 1}),
|
||||
},
|
||||
"optional": {
|
||||
}
|
||||
@@ -60,8 +60,10 @@ class LayerMaskTransform:
|
||||
_mask = _mask.resize((target_layer_width, target_layer_height))
|
||||
# rotate
|
||||
_, _mask, _ = image_rotate_extend_with_alpha(_mask.convert('RGB'), rotate, _mask, transform_method, anti_aliasing)
|
||||
paste_x = (orig_width - _mask.width) // 2 + x
|
||||
paste_y = (orig_height - _mask.height) // 2 + y
|
||||
# composit layer
|
||||
_mask_canvas.paste(_mask, (x, y))
|
||||
_mask_canvas.paste(_mask, (paste_x, paste_y))
|
||||
|
||||
ret_masks.append(image2mask(_mask_canvas))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user