PHP Imagick PDF 转 JPEG 问题
当我尝试将某些 pdf 文件转换为 JPEgs 时,出现此错误
错误消息是:
[28-Mar-2011 13:24:02] PHP Fatal error: Uncaught exception '
Stack trace:
#0 /home/bobdole/public_html/viewfile.php(41): Imagick->__con
#1 {main}
thrown in /home/bobdole/public_html/viewfile.php on line 41
代码是:
$im = new imagick($file_location);//Line 41 is here
$im->setImageFormat( "jpg" );
$pdf_pages=$im->getNumberImages();
知道是什么导致了问题以及如何解决它吗?这种情况并不总是发生,只有某些 PDF 才会发生。
GhostScript 已安装。
I am having this error that comes up when I try to convert certain pdfs into JPEgs
The error message is:
[28-Mar-2011 13:24:02] PHP Fatal error: Uncaught exception '
Stack trace:
#0 /home/bobdole/public_html/viewfile.php(41): Imagick->__con
#1 {main}
thrown in /home/bobdole/public_html/viewfile.php on line 41
The code is:
$im = new imagick($file_location);//Line 41 is here
$im->setImageFormat( "jpg" );
$pdf_pages=$im->getNumberImages();
Any idea what is causing the problem and how to fix it? It does not happen all the time, only with certain PDFs.
GhostScript is installed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我花了很多时间研究各种 PDF 文件和 imagemagick。这可能会帮助其他人尝试让这一切发挥作用。我在这里找到了很多解决方案,甚至不知道如何感谢大家,所以就在这里;)
经过大量无用的修补后,我认为不是 imagemagick 不起作用,而是 Ghostsript。我必须获得最新版本的 Ghostscript(我必须从源代码构建它,软件包不够新)。我用几乎所有可用的 PDF 版本对其进行了测试。更新 Ghostscript 效果很好,但仍然有一些 PDF 不被接受。
最后我检查了日志,发现 Ghostscript 字体是问题的关键。我更新了那些。这之后,一切都很顺利。现在实际上有一个可以转换任何 PDF 的网站。
I spent a lot of time playing around with all kinds of PDF-files and imagemagick. This might help others trying to get it all to work. I've found so many solutions here, wouldn't even know how to thank everyone, so here it goes ;)
After a lot of useless tinkering, I figured it wasn't imagemagick which didn't work, but Ghostsript. I had to get the latest version of Ghostscript (i had to build it from source, the packages weren't new enough). I tested it all with pretty much all the available PDF-versions. Updating ghostscript worked pretty well, but still some PDF's were not accepted.
In the end I checked out the logs and discovered that ghostscript fonts are key to the issue. I updated those. After this, it all went smooth. Actually have a site which converts any PDF, right now.