【发布时间】:2017-10-02 19:40:30
【问题描述】:
我知道 ghostscript 可以将 pdf 转换为 tiff,甚至有 python bindings,但我想知道是否有办法避免将生成的 tiff 写入磁盘 (-SOutputFile=/path/to/file.tiff。相反,我想保留生成的 tiff内存并将其用作 PIL 图像。
【问题讨论】:
标签: python pdf python-imaging-library ghostscript tiff
我知道 ghostscript 可以将 pdf 转换为 tiff,甚至有 python bindings,但我想知道是否有办法避免将生成的 tiff 写入磁盘 (-SOutputFile=/path/to/file.tiff。相反,我想保留生成的 tiff内存并将其用作 PIL 图像。
【问题讨论】:
标签: python pdf python-imaging-library ghostscript tiff
基本上,不,不使用标准设备。这是因为 TIFF 文件的条带大小(可能还有 TIFF 标头中的其他条目)在创建压缩位图之前无法写入,因为大小未知。所以你需要能够回到开头并更新标题。
现在您可以修改标准 TIFF 输出设备,以便它们将输出保存在内存中,而不是写入磁盘,但这不是它们当前的工作方式。
【讨论】: