noneplugin / nonebot-plugin-imageutils

Nonebot2 PIL工具插件
MIT License
45 stars 6 forks source link

BuildImage.circle_corner()生成的圆角矩形以及.circle()生成的圆形四角有黑色边缘 #20

Closed LambdaYH closed 1 year ago

LambdaYH commented 1 year ago

如图 8FR4N1QY3$YVR~{KU2U4DM5 %I2Y4I}{99}9WJ70E9OJ@JA

测试代码如下:

from nonebot import on_fullmatch
from nonebot.adapters.onebot.v11 import MessageSegment

from nonebot_plugin_imageutils import BuildImage

test = on_fullmatch("圆角矩形", priority=5, block=True)

@test.handle()
async def _():
    text_img = BuildImage.new(mode="RGBA", size=(80, 80), color=(230,230,230)).circle_corner(r=20)
    # text_img = BuildImage.new(mode="RGBA", size=(80, 80), color=(230,230,230)).circle()
    bg_img = BuildImage.new(mode="RGBA", size=(200, 200), color="white")
    bg_img.paste(text_img, pos=(20, 20), alpha=True)
    await test.send(MessageSegment.image(bg_img.save_png()))
MeetWq commented 1 year ago

逝世新版

LambdaYH commented 1 year ago

白色背景下没黑边了,但是非白色背景下出现了白色不透明四角( LJG)$53UVW{PLFWT}SUHR`Q

@test.handle()
async def _():
    text_img = BuildImage.new(
        mode="RGBA", size=(80, 80), color=(230, 230, 230)).circle_corner(r=20)
    # text_img = BuildImage.new(mode="RGBA", size=(80, 80), color=(230,230,230)).circle()
    bg_img = BuildImage.new(mode="RGBA", size=(200, 200), color=(128, 128, 128))
    bg_img.paste(text_img, pos=(20, 20), alpha=True)
    await test.send(MessageSegment.image(bg_img.save_png()))

https://github.com/noneplugin/nonebot-plugin-imageutils/blob/3b758df50b9b3ba0f8ac4773dbdcbe833a3ebebe/nonebot_plugin_imageutils/build_image.py#L155 https://github.com/noneplugin/nonebot-plugin-imageutils/blob/3b758df50b9b3ba0f8ac4773dbdcbe833a3ebebe/nonebot_plugin_imageutils/build_image.py#L165 这里改成

bg = Image.new("RGBA", image.size, (255, 255, 255, 0))

似乎就正常了

MeetWq commented 1 year ago

雀食

MeetWq commented 1 year ago

已经改了