【发布时间】:2023-01-21 16:53:13
【问题描述】:
我正在使用以下代码将 .emf 文件转换为 .jpg。
import os, sys
from PIL import Image
for infile in sys.argv[1:]:
f, e = os.path.splitext(infile)
outfile = f + ".jpg"
if infile != outfile:
try:
Image.open(infile).convert('RGB').save(outfile)
except IOError:
print("cannot convert", infile)
它会创建扩展名为 .jpg 的新文件,但该文件似乎是空白的。有什么建议么? 谢谢
我找到了另一篇建议添加以下内容的帖子:
从 PIL 导入 BmpImagePlugin、GifImagePlugin、Jpeg2KImagePlugin、JpegImagePlugin、PngImagePlugin、TiffImagePlugin、WmfImagePlugin
但是该文件似乎仍然是空白的。
【问题讨论】:
-
您使用的是 Windows 吗?您可以通过 Google 云端硬盘或类似工具共享 EMF 文件吗?
-
感谢您的回复。我正在使用 Windows。我实际上是通过使用“魔杖”来绕过它的,我相信它使用了 ImageMagick。
-
酷 - 考虑将您的代码作为答案,以便其他人可以看到您是如何做到的。
标签: python python-imaging-library file-conversion