python-django Ghostscript apache 问题

发布于 2024-11-03 03:42:44 字数 553 浏览 0 评论 0原文

当我运行我的应用程序时,它将 pdf 从 django 服务器转换为 png,转换工作正常。但是当我从 apache 服务器运行此程序时,我收到此错误:GhoscriptError:致命。从 Ghostscript 的 sterr 中读到,它说

初始化文件gs_init.ps确实 不以整数开头。

对我来说这似乎是一个初始化错误,但我不知道如何解决这个问题。

顺便用一下Ubuntu。 gs 文件夹位于路径中,所以我不确定这是否导致了问题。

这是我生成图像的代码

def PDF_to_png(输入,输出):

<前><代码>参数= [ “-dSAFER”, “-dBATCH”,“-dNOPAUSE”,“-sDEVICE=png16m”, “-r300”, "-sOutputFile=" + os.path.join(输出,input.file_name_without_extension)+"_%d.png", 输入 ] Ghostscript.Ghostscript(*args)

When I run my app, that converts pdf to png, from django server, the conversion works fine. But when I run this from an apache server, I am getting this error: GhoscriptError: Fatal. Reading from the sterr of ghostscript, it says

Initialization file gs_init.ps does
not begin with an integer.

It seems an initialization error for me, but I have no idea how to fix this.

Using Ubuntu by the way. gs folder is in the path, so Im not sure if that is causing the problem.

Here's my code that generates the images

def PDF_to_png(input,output):

args = [
"-dSAFER",
"-dBATCH", "-dNOPAUSE", "-sDEVICE=png16m",
"-r300",
"-sOutputFile=" + os.path.join(output,input.file_name_without_extension)+"_%d.png",
input
]
ghostscript.Ghostscript(*args)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜空下最亮的亮点 2024-11-10 03:42:44

该错误告诉您通常在 gs/Resource/Init/ 中找到的文件 gs_init.ps 无效。从文件的标题来看:

------------------------------------------------------------------------
% Interpreter library version number
% NOTE: the interpreter code requires that the first non-comment token
% in this file be an integer, and that it match the compiled-in version!
902
------------------------------------------------------------------------

您可以使用内置资源或磁盘上的资源构建 GS,我不知道您使用 Ubuntu 获得哪个版本,但听起来要么有一个 gs_init.ps在已损坏的 GS 路径中。这可能意味着您使用的版本具有磁盘上的资源。

您应该首先尝试启动 Ghostscript。如果这有效,那么这与运行失败实例时的环境不同有关。查找以 GS_ 开头的环境变量(尤其是 *GS_LIB*)。您还应该尝试实际定义 GS 在命令行上应查看的位置,包括以下内容:

-I/usr/src/gs/Resource

I 包含指定目录作为 Ghostscript 的搜索路径(注意 GS 不使用 PATH 环境变量)。 GS 将首先在此处搜索初始化文件,然后再继续其回退机制。

The error is telling you that the file gs_init.ps which is normally found in gs/Resource/Init/ is not valid. From the header of the file:

------------------------------------------------------------------------
% Interpreter library version number
% NOTE: the interpreter code requires that the first non-comment token
% in this file be an integer, and that it match the compiled-in version!
902
------------------------------------------------------------------------

You can build GS with the resources built-in or on disk, I don't know which build you get with Ubuntu but it sounds like either there is a gs_init.ps in the GS path which has been damaged. This probably means you are using a version with the resources on disk.

You should first try just starting up Ghostscript. If that works then it's something to do with the environment which is different when you run the failing instance. Look for environment variables which begin GS_ (especially *GS_LIB*). You should also try actually defining where GS should look on the command line by including something like :

-I/usr/src/gs/Resource

This I ncludes the specified directory as a search path for Ghostscript (NB GS does not use the PATH environment variable). GS will search here for initialisation files first before proceeding on its fall back mechanism.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文