我正在努力从Python的io.BufferedReader
类的实例中正确地打开TIFF图像。我使用下面的lib从GCS路径下载图像,但我无法打开,似乎用传统工具打开图像。在
# returns the <_io.BufferedReader>
file = beam.io.gcp.gcsio.GcsIO().open("<GCS_PATH>", 'r')
from PIL import Image
img = Image.open(file.read()) <---- Fails with "TypeError: embedded NUL character"
img = Image.open(file.raw) <--- Fails when any operations are performed with "IOError(err)"
除了PIL之外,我还对其他图书馆开放。在
以下也失败了: 它失败,返回IOError,声明tempfile.tif: Cannot read TIFF header.
请确保将两者都包装在ContextManager中,以便它们都能正确关闭。在
相关问题 更多 >
编程相关推荐