如何将点或虚线添加到Python中的PNG?
您好,我想画一条虚线或虚线到PNG,我找不到我该怎么做,有人可以帮忙吗?
im = image.new('rgb',(2000,2000),元组(int(hex_color [i:i+2],16,16),for In(0,2,4)))打印(0,2,4))。 .. saving ...“)im.save('c:\\ users \\ th3m1s \\ desktop \\ lejant \\'+str(legend_code)+'。png',质量= 100)
结果是单击此处
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否考虑过使用垂直线和水平线创建新图像,比原始图像略高略高,更宽,您粘贴了原始图像?
这样,您将有一个虚线的边框,并且适用于各种尺寸。
这可以如下所述完成:
“>在您的情况下, 如果您将自己的图像粘贴在中心,则在2010年将是2010年的新图像,使您在两边都有5px。
Have you considered creating a new image with vertical lines as well as horizontal lines, slightly taller and wider than your original image, on which you paste your original image?
That way you will have a dotted border and it works for every size.
This can be done as explained here: How do you composite an image onto another image with PIL in Python?
In your case, if you want your border to be 5px all the way around your image, and your image is 2000,2000, changing the size of the new image to be 2010 by 2010 leaves you with 5px to spare on both sides if you paste your own image in the center.