我遇到了imagick
php 库的问题。
我正在我的文件系统中进行递归搜索并查找任何pdf
文件。
$it = new RecursiveDirectoryIterator("/test/project");
$display = Array ('pdf');
foreach(new RecursiveIteratorIterator($it) as $file){
if (in_array(strtolower(array_pop(explode('.', $file))), $display))
{
if(file_exists($file)){
echo $file; //this would echo /test/project/test1.pdf
$im = new Imagick($file);
$im->setImageFormat("jpg");
file_put_contents('test.txt', $im);
}
}
}
但是,我收到一条错误消息
Fatal error: Uncaught exception 'ImagickException' with message 'Can not process empty Imagick object' in /test.php:57
Stack trace:
#0 /test.php(57): Imagick->setimageformat('jpg')
#1 {main}
thrown in /test.php on line 57
line 57 is $im->setImageFormat("jpg");
但是,如果我用错误代替我$im = new Imagick($file)
的$im = new Imagick('/test/project/test1.pdf'),
错误就消失了。
我不知道为什么会这样。有人可以给我这个问题的提示吗?非常感谢