我试图用PIL打开PyFileSystem MemoryFS中的映像文件,我试图像这个例子一样这样做,但我得到了以下错误:
from PIL import Image
from fs.memoryfs import MemoryFS
fs=MemoryFS()
fs.makedir("test")
out=fs.open("test/file.jpg",'wb')
out.write(someimagefile.read())
out.close()
in=fs.open("test/file.jpg",'rb')
im=Image.open(in) #error: cannot identify image file <IO wrapper for <MemoryFile in <MemoryFS> test/file.jpg>>
但是,如果我不使用目录(例如out=fs.open("file.jpg",'wb')
),它会按预期工作。
我做错什么了? 谢谢你的帮助。
我已经收到一个错误使用以下行:
可能我没有安装那个库。你需要这个图书馆吗?您只需打开图像而不必使用内存打开它:
^{pr2}$旁注:我不会使用
in
作为变量名,因为它也是一个Python关键字。在相关问题 更多 >
编程相关推荐