[英]Is it possible to convert an entire PDF file to a bunch images using ImageMagick (Ubuntu, Python)?
I have a Python app which among others converts an entire PDF file to a few jpg.我有一个 Python 应用程序,它可以将整个 PDF 文件转换为几个 jpg。 In Pycharm it is implemented by the code:
在 Pycharm 中它是由代码实现的:
import subprocess
subprocess.check_call(["magick",Platforma_IoT.pdf,Platforma_IoT.jpg], shell=True)
That code in Pycharm on Windows 10 works completely fine, it converts every page of a pfd to jpg. Windows 10 上 Pycharm 中的代码完全正常,它将 pfd 的每一页都转换为 jpg。 But now I want to run that code using Bash console.
但是现在我想使用 Bash 控制台运行该代码。 Unfortunately, I am getting an error in the Bash:
不幸的是,我在 Bash 中遇到错误:
import-im6.q16: unable to open X server `' @ error/import.c/ImportImageCommand/358.
./sd.py: line 3: syntax error near unexpected token `["magick","Platforma_IoT.pdf","Platforma_IoT.jpg"],'
./sd.py: line 3: `subprocess.check_call(["magick","Platforma_IoT.pdf","Platforma_IoT.jpg"], shell = True)'
I also tried that code:我也试过那个代码:
import subprocess
subprocess.check_call(["convert","Platforma_IoT.pdf","Platforma_IoT.jpg"])
But I am getting the same error in the bash.但是我在 bash 中遇到了同样的错误。
I just want to run code which converts every page of PDF to an image using bash console.我只想运行代码,使用 bash 控制台将 PDF 的每一页转换为图像。 How can I do that?
我怎样才能做到这一点?
You met a wrong script interpretation.您遇到了错误的脚本解释。 Use shebang to define the right interpretator:
使用 shebang 定义正确的解释器:
#!/usr/bin/env python3
Or you can launch your script in python directly:或者你可以直接在 python 中启动你的脚本:
python3 script.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.