在 C# 中,我可以使用Bitmap.lockbits()
以字节数组形式访问位图。如何在 PIL 中执行此操作?我努力了Image.write()
但它将完整格式的图像写入流中。
from io import BytesIO
from PIL import Image
with BytesIO() as output:
with Image.open(path_to_image) as img:
img.save(output, 'BMP')
data = output.getvalue()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)