【问题标题】:Using subprocess.run to convert a file to one type to another使用 subprocess.run 将文件从一种类型转换为另一种类型
【发布时间】:2019-08-02 12:10:28
【问题描述】:

我有以下 python 指令:

subprocess.run('gswin64c -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=C:/Users/ingNC/Desktop/results/Sub-frame4.png C:/Users/ingNC/Desktop/test/Sub-frame4.ps', shell=True, check=True, text=True)

我有 .ps 文件“Sub-frame4.ps”,我想将此文件转换为名为“Sub-frame4.png”的 .png 文件,并将后者保存在“results”文件夹中。在运行指令之前,我需要创建文件“Sub-frame4.png”吗?或者这个文件会在命令执行过程中创建?

【问题讨论】:

    标签: python-3.x subprocess ghostscript


    【解决方案1】:

    ghostscript 命令将创建文件。

    【讨论】:

    • 谢谢。我试图在 python 文件中运行这个命令,我得到一个退出状态1。所以,我尝试了:gswin64c -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=C:/Users/ingNC/Desktop/results/Sub-frame4.png C:/Users/ingNC/Desktop/test/Sub-frame4。 ps 在命令提示符下,我收到一条错误消息“'gswin64c' 不被识别为内部或外部命令、可运行程序或批处理文件”。由于ghotscript是python的实习生模块,我不明白重点是什么。请问,你有什么想法吗?
    • 我不知道您所说的“ghostscript 是 Python 的临时模块”是什么意思。 Ghostscript 是一个可执行文件。你真的安装了 Ghostscript 吗?您是否已将 Ghostscript 路径添加到您的 $PATH 环境变量中。
    猜你喜欢
    • 2011-09-24
    • 1970-01-01
    • 2012-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多