python - Imagemagick 通过 Python 转换
问题描述
我有一堆我想使用 python 转换为 .tiffs 的 PDFS。
data_path = " some path "
tiff path = " some path "
data_list = os.listdir(data_path)
for f in data_list:
if (os.path.isfile(os.path.join(data_path, f)) and f.endswith(".pdf")):
process = subprocess.Popen(
["convert", os.path.join(data_path, f), "-density 300", os.path.join(tiff_path, f+".tiff")],
stdout = subprocess.PIPE,
stderr = subprocess.PIPE
)
stdout, stderr = process.communicate()
print("stdout", stdout)
print("stderr", stderr)
如果没有“-density 300”,上述工作正常。当我使用该选项(或任何其他选项)时,它会引发以下错误:
stdout b''
stderr b"convert: unrecognized option `-density 300' @ error/convert.c/ConvertImageCommand/1427.\n"
stdout b''
stderr b"convert: unrecognized option `-density 300' @ error/convert.c/ConvertImageCommand/1427.\n"
stdout b''
stderr b"convert: unrecognized option `-density 300' @ error/convert.c/ConvertImageCommand/1427.\n"
该命令在终端上运行良好。任何修复它的帮助表示赞赏。提前致谢。
注意:我在 MacOS 上。
解决方案
推荐阅读
- google-maps - 将应用程序(地图、分析等)从 google play 迁移到华为应用程序库
- javascript - 通过jquery数据表中的主键进行数据排序
- verilog - 延迟计数器不增加?密克罗尼西亚联邦
- django - 我可以停止大量的 [Django] ERROR (EXTERNAL IP): Invalid HTTP_HOST header from 陌生网站吗?
- angular - 根据特定场景显示 div
- java - 注册时尝试向 Firebase 用户添加新的数据字段,但 FirebaseUser.class 文件中没有更新 X 方法
- blazor - 注入从 RevalidatingServerAuthenticationStateProvider 继承的类
- android - google play billing v4 中是否弃用了 PendingIntent (BUY_INTENT)
- python - Flask 和 Vue 未在树莓派零上连接
- android - 如何像 WhatsApp 个人资料图片一样显示模糊图像?