[英]PHP imagick with PDF issue
I am trying to convert the first page of a PDF to an image file. 我正在尝试将PDF的首页转换为图像文件。
I have the following code: 我有以下代码:
$im = new imagick('/images/test.pdf[0]');
$im->setImageFormat("jpg");
$page=$im->queryFormats();
echo "<pre>";
print_r ($page);
echo "</pre>";
However, I get an error message saying: 但是,我收到一条错误消息:
Uncaught exception 'ImagickException' with message 'unable to open image
If I change: 如果我更改:
$im = new imagick('/images/test.pdf[0]');
to: 至:
$im = new imagick('/images/test.pdf');
I get the following error: 我收到以下错误:
Uncaught exception 'ImagickException' with message 'Unable to read the file
I am sure the path to my PDF is correct and I'm not sure how to solve this. 我确定我的PDF路径正确,并且不确定如何解决此问题。 Can anyone help me out with this?
谁能帮我这个忙吗?
Do you have a /images
folder in the ROOT of your drive? 您的驱动器根目录中是否有一个
/images
文件夹? Remember - imagick is running within PHP and has no clue whatsoever what your site's URL-space structure is. 请记住-imagick在PHP中运行,并且不知道您网站的URL空间结构是什么。 You need to use the local file system path, eg
您需要使用本地文件系统路径,例如
$im = new imagick('/path/to/example.com/html/images/test.pdf[0]');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.