编辑:Ghostscript 可以给我二进制数据而不是输出到目录吗?
EDIT: Can Ghostscript give me the binary data rather than output to a directory?
我目前有一个 Python 脚本,它运行 Ghostscript 命令将 PDF 的第一页转换为 PNG。但是,现在图像只是进入我的目录之一。是否可以让 Ghostscript 输出二进制数据,以便我可以将其保存到数据库中?
args = [
"pdf2img", # actual value doesn't matter
"-sOutputFile=testing.png",
"-dNOPAUSE",
"-dBATCH",
"-sDEVICE=png256",
"-sPAPERSIZE=a1",
"-dPDFFitPage=true",
"-dFirstPage=1",
"-dLastPage=1",
"testPDF.pdf"
]
ghostscript.Ghostscript(*args)
您可以通过说 -sOutputFile=%stdout 让 Ghostscript 将输出通过管道传输到 stdout。除此之外,我想不出你所说的 'give you the binary data'.
是什么意思
我目前有一个 Python 脚本,它运行 Ghostscript 命令将 PDF 的第一页转换为 PNG。但是,现在图像只是进入我的目录之一。是否可以让 Ghostscript 输出二进制数据,以便我可以将其保存到数据库中?
args = [
"pdf2img", # actual value doesn't matter
"-sOutputFile=testing.png",
"-dNOPAUSE",
"-dBATCH",
"-sDEVICE=png256",
"-sPAPERSIZE=a1",
"-dPDFFitPage=true",
"-dFirstPage=1",
"-dLastPage=1",
"testPDF.pdf"
]
ghostscript.Ghostscript(*args)
您可以通过说 -sOutputFile=%stdout 让 Ghostscript 将输出通过管道传输到 stdout。除此之外,我想不出你所说的 'give you the binary data'.
是什么意思