from PIL import Image
# 打开图片
img = Image.open("hzw.jpg")
# 展示图片
# img.show()
# 打印图片信息
print(img.format, img.size, img.mode)
# 保存图片
# img.save()
# 图像通道分离与合并
# r, g, b = img.split()
# print(r.size, r.mode)
# img1 = Image.merge("RGB", (r, g, g))
# img1.show()
# 图像区域
# box = img.copy()
# box = (100, 100, 400, 400)
# region = img.crop(box)
# region.show()
# 图像缩放 旋转和翻转
# out = img.resize(128, 128)
# out.show()
# out = img.rotate(45)
# out.show()
# out = img.transpose(Image.FLIP_LEFT_RIGHT)
# out.show()
# out = img.transpose(Image.FLIP_TOP_BOTTOM)
# out.show()
# out = img.transpose(Image.ROTATE_90)
# out.show()