简体   繁体   English

为什么imagick不起作用?

[英]Why doesn't imagick work?

<?php
$im = new imagick('vui.pdf[0]');
$im->setImageFormat( "png" );
header( "Content-Type: image/jpeg" );
echo $im;
?>

I am using heliohost, but when i run this script, it show me a 500 Internal Server Error (http://iamsnoob.co.cc/open.php ), why? 我正在使用heliohost,但是运行此脚本时,它显示500内部服务器错误(http://iamsnoob.co.cc/open.php),为什么?

This is a wild guess, but ImageMagick requires Ghostscript to be able to open PDF files. 这是一个疯狂的猜测,但是ImageMagick要求Ghostscript能够打开PDF文件。 It could be that Ghostscript is not present. 可能是Ghostscript不存在。

I would try with a JPEG image first. 我会先尝试使用JPEG图像。 If that works with the same syntax, it's likely to be that. 如果该命令使用相同的语法,则很可能是这样。

The very best thing would be to look into the error logs and see what the 500 error is about exactly. 最好的办法是查看错误日志,看看500错误到底是什么。 Some providers offer access to the error log through their control panels or FTP logins. 某些提供程序通过其控制面板或FTP登录名提供对错误日志的访问。

Edit : A user has this to say in the PHP manual on Imagick : 编辑 :用户可以在Imagick上PHP手册中这样说:

To load image (usually vector image, like PDF) with larger resolution than image's default is, you have to set resolution before reading the file, like this: 要加载分辨率大于图像默认值的图像(通常是矢量图像,如PDF),您必须在读取文件之前设置分辨率,如下所示:

 <?php $im = new Imagick(); $im->setResolution( 300, 300 ); $im->readImage( "test.pdf" ); ?> 

this may well be the issue - try setting a lower resolution. 这很可能是问题-尝试设置较低的分辨率。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM