首先尝试将原始数据加载到BytesIO
容器中:
from io import BytesIO
from PIL import Image
from subprocess import Popen, PIPE
data = Popen.communicate(Popen(['import','-w','0x02a00001','png:-'], stdout=PIPE))[0]
scr = Image.open(BytesIO(data))
Python ValueError:从bash管道读取png文件时嵌入了空字节
首先尝试将原始数据加载到BytesIO
容器中:
from io import BytesIO
from PIL import Image
from subprocess import Popen, PIPE
data = Popen.communicate(Popen(['import','-w','0x02a00001','png:-'], stdout=PIPE))[0]
scr = Image.open(BytesIO(data))