如何安装,测试,转换,使用ImageMagick,Ghostscript的,Windows Vista中/ 7 64位系统调整PDF测试、系统、Ghostscript、ImageMagick

2023-09-07 18:14:20 作者:拾荒者

我有麻烦越来越ImageMagick的和Ghostscript共同努力 - 一切似乎很难,从安装,测试,实际使用该软件。有没有人有什么建议吗?

I'm having trouble with getting ImageMagick and Ghostscript to work together - everything seems difficult, from installation, to testing, to actually using the software. Does anyone have any tips?

推荐答案

我刚刚度过了最后三个小时来往的ImageMagick用PHP很好地发挥了PDF格式为JPG格式转换。相反,在本地记录它自己的,我想我会写在这里,所有的流行语和事情,我搞砸了,所以接下来的菜鸟可以节省一些时间。

I've just spent the last three hours getting ImageMagick to play nicely with PHP for a PDF to JPG convert. Instead of documenting it myself locally, I figured I'd write it up here, with all the buzzwords and things I screwed up, so the next noob can save some time.

测试两个操作系统中,Windows 7 x64和Vista 64位,使用PHP 5.2.8和Apache 2.2.11。

Tested on two OSs,Windows 7 x64 and Vista x64, with PHP 5.2.8 and Apache 2.2.11.

您需要的Ghostscript和ImageMagick的。我得到了 gs871w64.exe 的ImageMagick-6.6.3-0-Q16-窗口-64-dll.exe

You'll need Ghostscript and ImageMagick. I got gs871w64.exe and ImageMagick-6.6.3-0-Q16-windows-x64-dll.exe.

做一个基本的ImageMagick的安装(我现在把它称为IM)。仔细检查系统路径变量,以确保您可以从任何地方IM。它应该指向IM目录。测试与这条线的安装 CMD 转换test.gif test.jpg放在(假设你有 test.gif )。工程确定。

Do a basic install of ImageMagick (I'll call it IM now). Double check the system path variable to ensure you can IM from anywhere. It should point to the IM directory. Test the installation with this line in cmd: convert test.gif test.jpg (assuming you have test.gif). Works OK.

测试一个PDF转换(转换的test.pdf test.jpg放在)。你应该得到一个(长)消息关于gswin32c.exe和后记委托失败和丢失的图像文件名。这意味着IM不能找到一个PDF翻译。你需要Ghostscript的。

Test a PDF convert (convert test.pdf test.jpg). You should get a (long) message about "gswin32c.exe" and "Postscript delegate failed" and "missing an image filename". That means IM can't find a PDF 'translator'. You need Ghostscript.

安装的Ghostscript(我会打电话给现在GS)。我不得不做两次由于某种原因,之前花了。添加'本'的地址中的GS文件夹系统变量。测试安装与 gswin32的test.pdf ,你会看到你的文件弹出的GS观众。重要提示: GS不能在Windows(GS不被识别为一个内部或外部命令,可操作的程序或批处理文件)。你需要使用 gswin32

Install Ghostscript (I'll call it GS now). I had to do it twice for some reason before it took. Add the 'bin' address in the GS folder to the system variable. Test the installation with gswin32 test.pdf and you should see your file pop up in the GS viewer. Important note: gs doesn't work in Windows ('gs' is not recognized as an internal or external command, operable program, or batch file.). You need to use gswin32.

回到IM测试:转换的test.pdf test.jpg放在现在应该工作

Back to the IM test: convert test.pdf test.jpg should work now.

现在切换到PHP - 写了这个剧本:

Now over to PHP - write up this script:

$out = shell_exec("convert blah.pdf blah2.jpg 2>&1");
echo $out;

2 - ;&功放; 1 的将移动所有错误到标准输出这样你就可以更好地诊断的东西:)。现在,你的PHP脚本可以在CMD提示符下运行,但是当你在浏览器中运行它没有任何反应。嫌你的额头,并重新启动Apache。

The 2>&1 will move all errors into the standard output so you can better diagnose stuff :). Now, your PHP script may run in the cmd prompt, but nothing happens when you run it in a browser. Smack your forehead and restart Apache.

裤子的详尽,大概小学,我知道了。但是,大约20页的半有用的线索希望有用的摘要。

pant Exhaustive and probably elementary, I know. But a hopefully helpful summary of approximately 20 pages of semi-helpful clues.