打印imagemagick将输出转换为眉毛

2024-10-02 20:42:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下代码:

import subprocess
convertargs = ['convert', 'image1.tif', 'img2.tif', 'pdf:-']
print "Content-type: application/pdf\r\n\r\n"

pdf = subprocess.Popen(convertargs, stdout=subprocess.PIPE)
pdf, error = pdf.communicate()

print pdf

它应该使用convertargs,使用imagemagick的convert将图像转换成pdf。你知道吗

我知道这是可行的,因为当我在shell中运行以下命令时:

./pdf.py > test.pdf

它为我创建了一个整洁的小PDF与正确的图像。然而,当我去上学的时候,它不起作用www.myhost.com/pdf.py。我不知道为什么。 我的apache错误日志是这样写的:

Traceback (most recent call last):: /Library/WebServer/Documents/pdf.py
   File "/Library/WebServer/Documents/pdf.py", line 59, in <module>: /Library/WebServer/Documents/pdf.py
     pdf = subprocess.Popen(convertargs, stdout=subprocess.PIPE): /Library/WebServer/Documents/pdf.py
   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__: /Library/WebServer/Documents/pdf.py
     errread, errwrite): /Library/WebServer/Documents/pdf.py
   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child: /Library/WebServer/Documents/pdf.py
     raise child_exception: /Library/WebServer/Documents/pdf.py
OSError: [Errno 2] No such file or directory: /Library/WebServer/Documents/pdf.py

Tags: inpyconvertpdfstdoutlinelibrarydocuments