PIL

读取

# 读取
img = Image.open('/home/bovenson/Downloads/Other/mnist-test/4.3192.jpg')

图片信息

from PIL import Image

# 读取
img = Image.open('/home/bovenson/Downloads/Other/mnist-test/4.3192.jpg')

# 打印图片信息
print('Filename:\t', img.filename)
print('Format:\t', img.format)
print('Mode:\t', img.mode)
print('Size:\t', img.size)
print('Width:\t', img.width)
print('Height:\t', img.height)
print('Palette:\t', img.palette)
print('Info:\t', img.info)

输出:

旋转

保存

API: Image.save(fp, format=None, **params)

  • fp: 可以是文件名(字符串类型), pathlib.Path对象或者file对象.

  • format: 保存的图片格式.

最后更新于

这有帮助吗?