fix: parse fx resize y scale argument
This commit is contained in:
@ -193,7 +193,7 @@ class ImageFilterImplement:
|
|||||||
|
|
||||||
# 缩放
|
# 缩放
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def apply_resize(image: Image.Image, scale: float = 1.5, scale_y = None) -> Image.Image:
|
def apply_resize(image: Image.Image, scale: float = 1.5, scale_y: float = None) -> Image.Image:
|
||||||
scale_x = float(scale)
|
scale_x = float(scale)
|
||||||
scale_y_value = float(scale_y) if scale_y is not None else None
|
scale_y_value = float(scale_y) if scale_y is not None else None
|
||||||
|
|
||||||
|
|||||||
@ -14,6 +14,13 @@ fx_handle = module_from_spec(SPEC)
|
|||||||
SPEC.loader.exec_module(fx_handle)
|
SPEC.loader.exec_module(fx_handle)
|
||||||
ImageFilterImplement = fx_handle.ImageFilterImplement
|
ImageFilterImplement = fx_handle.ImageFilterImplement
|
||||||
|
|
||||||
|
INIT_MODULE_PATH = Path(__file__).resolve().parents[1] / "konabot/plugins/fx_process/__init__.py"
|
||||||
|
INIT_SPEC = spec_from_file_location("test_fx_init_module", INIT_MODULE_PATH)
|
||||||
|
assert INIT_SPEC is not None and INIT_SPEC.loader is not None
|
||||||
|
fx_init = module_from_spec(INIT_SPEC)
|
||||||
|
INIT_SPEC.loader.exec_module(fx_init)
|
||||||
|
prase_input_args = fx_init.prase_input_args
|
||||||
|
|
||||||
|
|
||||||
def test_apply_jpeg_damage_keeps_size_and_rgba_mode():
|
def test_apply_jpeg_damage_keeps_size_and_rgba_mode():
|
||||||
image = Image.new("RGBA", (32, 24), (255, 0, 0, 128))
|
image = Image.new("RGBA", (32, 24), (255, 0, 0, 128))
|
||||||
@ -71,3 +78,11 @@ def test_apply_resize_negative_scale_without_y_flips_both_axes():
|
|||||||
assert result.getpixel((1, 0)) == (0, 0, 255, 255)
|
assert result.getpixel((1, 0)) == (0, 0, 255, 255)
|
||||||
assert result.getpixel((0, 1)) == (0, 255, 0, 255)
|
assert result.getpixel((0, 1)) == (0, 255, 0, 255)
|
||||||
assert result.getpixel((1, 1)) == (255, 0, 0, 255)
|
assert result.getpixel((1, 1)) == (255, 0, 0, 255)
|
||||||
|
|
||||||
|
|
||||||
|
def test_prase_input_args_parses_resize_second_argument_as_float():
|
||||||
|
filters = prase_input_args("缩放 2 3")
|
||||||
|
|
||||||
|
assert len(filters) == 1
|
||||||
|
assert filters[0].name == "缩放"
|
||||||
|
assert filters[0].args == [2.0, 3.0]
|
||||||
|
|||||||
Reference in New Issue
Block a user