电子说
img = Image.open("./data/猫咪图片.jpg")
img_rotated = img.rotate(15,center = (0,0)) #以center为中心逆时针旋转
img_rotated
img = Image.open("./data/猫咪图片.jpg")
# 左右翻转
img_left_right = img.transpose(Image.FLIP_LEFT_RIGHT)
img_left_right
# 上下翻转
img_top_bottom = img.transpose(Image.FLIP_TOP_BOTTOM)
img_top_bottom
img = Image.open("./data/猫咪图片.jpg")
img_edges = img.filter(ImageFilter.FIND_EDGES)
img_edges
img = Image.open("./data/猫咪图片.jpg")
img_blur = img.filter(ImageFilter.GaussianBlur(radius=3))
img_blur
img = Image.open("./data/猫咪图片.jpg")
draw = ImageDraw.Draw(img)
arial = ImageFont.truetype('./data/simsun.ttc', 46)
draw.text((250,450),"敢梭哈吗?",font =arial, fill="white")
img
img = Image.open("./data/猫咪图片.jpg")
draw = ImageDraw.Draw(img)
draw.line([0,0,641,641],fill = "red",width = 5)
img
img = Image.open("./data/猫咪图片.jpg")
draw = ImageDraw.Draw(img)
draw.rectangle([78,24,455,320], fill=None, outline ='lawngreen',width = 5)
img
img = Image.open("./data/猫咪图片.jpg")
draw = ImageDraw.Draw(img)
draw.arc(xy = [78,24,455,320],start = 0,end = 360,fill="red",width=5)
img
img = Image.open("./data/猫咪图片.jpg")
img_resized = img.resize((150,150))
img.paste(img_resized,box = [460,50])
img
以上就是 pillow 的一些基本操作。对pillow和图像处理方面有其他疑问或想法,可以在留言区中讨论交流,具体代码问题可发在我们的论坛上(附上必要的代码和输出)。
全部0条评论
快来发表一下你的评论吧 !