绘制线的代码如下:
draw = ImageDraw.Draw(image_frame) draw.polygon([(left, top), (left+width-1, top), (left+width-1, top+height-1), (left, top+height-1)], outline=(255, 0, 0))
保存为图片时会发现,线只有一个像素,怎么办?这个时候,移动一个像素,再绘制一次:
left += 1 top += 1 draw.polygon([(left, top), (left+width-1, top), (left+width-1, top+height-1), (left, top+height-1)], outline=(255, 0, 0))
如果觉得还是不够粗,再移动像素绘制.