I have used PIL
#back_color_width
for x in range(w):
for y in range(h):
if x==0 or y==0 or x==w-1 or y==h-1 :
pixels[x,y] = back_color
I need to add a border to the image with a width on all 4 sides of image
解决方案
This is what you need to change to make the border any number of px wide:
for x in range(w):
for y in range(h):
if (x
or y
or x>w-border_width-1
or y>h-border_width-1):
pixels[x,y] = (0,0,0)
#other 3 boxes and #primary box Doesn't make boxes but instead 3 points and 1 point respectively.
本文介绍如何使用Python的PIL库为图像添加边框,方法是通过修改像素来实现任意宽度的边框效果,适用于图像处理和美化。
2641

被折叠的 条评论
为什么被折叠?



