update threshold for image merge

This commit is contained in:
felinae98 2021-12-24 14:20:05 +08:00
parent 4468de6f7a
commit 3f906f7a41
No known key found for this signature in database
GPG Key ID: 00C8B010587FF610
2 changed files with 22 additions and 1 deletions

View File

@ -42,7 +42,7 @@ class Post:
return Image.open(pic_buffer)
def _check_image_square(self, size: tuple[int, int]) -> bool:
return abs(size[0] - size[1]) / size[0] < 0.01
return abs(size[0] - size[1]) / size[0] < 0.05
async def _pic_merge(self) -> None:
if len(self.pics) < 3:

View File

@ -21,6 +21,20 @@ merge_source_9 = [
"https://wx4.sinaimg.cn/large/0071VPLMgy1gq0vifc826j30rs4a64qs.jpg",
"https://wx1.sinaimg.cn/large/0071VPLMgy1gq0vify21lj30rsbj71ld.jpg",
]
merge_source_9_2 = [
'https://wx2.sinaimg.cn/large/0071VPLMgy1gxo0eyycd7j30dw0dd3zk.jpg',
'https://wx1.sinaimg.cn/large/0071VPLMgy1gxo0eyx6mhj30dw0ddjs8.jpg',
'https://wx4.sinaimg.cn/large/0071VPLMgy1gxo0eyxf2bj30dw0dddh4.jpg',
'https://wx3.sinaimg.cn/large/0071VPLMgy1gxo0ez1h5zj30dw0efwfs.jpg',
'https://wx3.sinaimg.cn/large/0071VPLMgy1gxo0eyyku4j30dw0ef3zm.jpg',
'https://wx1.sinaimg.cn/large/0071VPLMgy1gxo0ez0bjhj30dw0efabs.jpg',
'https://wx4.sinaimg.cn/large/0071VPLMgy1gxo0ezdcafj30dw0dwacb.jpg',
'https://wx1.sinaimg.cn/large/0071VPLMgy1gxo0ezg2g3j30dw0dwq51.jpg',
'https://wx3.sinaimg.cn/large/0071VPLMgy1gxo0ez5oloj30dw0dw0uf.jpg',
'https://wx4.sinaimg.cn/large/0071VPLMgy1gxo0fnk6stj30rs44ne81.jpg',
'https://wx2.sinaimg.cn/large/0071VPLMgy1gxo0fohgcoj30rs3wpe81.jpg',
'https://wx3.sinaimg.cn/large/0071VPLMgy1gxo0fpr6chj30rs3m1b29.jpg'
]
@pytest.mark.asyncio
async def test_9_merge(plugin_module: 'nonebot_bison'):
@ -29,6 +43,13 @@ async def test_9_merge(plugin_module: 'nonebot_bison'):
assert len(post.pics) == 5
await post.generate_messages()
@pytest.mark.asyncio
async def test_9_merge_2(plugin_module: 'nonebot_bison'):
post = plugin_module.post.Post('', '', '', pics=merge_source_9_2)
await post._pic_merge()
assert len(post.pics) == 4
await post.generate_messages()
@pytest.mark.asyncio
async def test_6_merge(plugin_module):
post = plugin_module.post.Post('', '', '', pics=merge_source_9[0:6]+merge_source_9[9:])