php
fatal error: uncaught exception 'imagickexception' with message 'unable to open image `papers/1375680721.pdf': no such file or directory @ error/blob.c/openblob/2622' in c:\xampp\htdocs\fc\editpaper.php:38 stack trace: #0
c:\xampp\htdocs\fc\editpaper.php(38): imagick->readimage('papers/13756807...') #1 c:\xampp\htdocs\fc\editpaper.php(108): pdf2png('papers/13756807...', 'papers/', 0) #2 c:\xampp\htdocs\fc\editpaper.php(211): anli->insert('') #3 {main} thrown in c:\xampp\htdocs\fc\editpaper.php on line 38
报如下错误
function pdf2png($pdf,$topath,$page){ if(!extension_loaded('imagick')){ echo imagick; return false; } if(!file_exists($pdf)){ echo noexists; return false; } $im = new imagick(); $im->setresolution(1000,2000); $im->setcompressionquality(100); $im->readimage($pdf.[.$page.]); foreach ($im as $key => $var){ $var->setimageformat('png'); $filename = $topath.time().'_'.$key.'.png'; if($var->writeimage($filename) == true){ $return[] = $filename; } } return $return;}
回复讨论(解决方案) 他说的很明确了,papers/1375680721.pdf 不存在
他说的很明确了,papers/1375680721.pdf 不存在 不是这个原因,文件是存在的
'unable to open image `papers/1375680721.pdf': no such file or directory
“无法打开图像papers/1375680721.pdf”:没有这样的文件或目录
'unable to open image `papers/1375680721.pdf': no such file or directory
“无法打开图像papers/1375680721.pdf”:没有这样的文件或目录
@ error/blob.c/openblob/2622' 这个错误是什么意思?
'unable to open image `papers/1375680721.pdf': no such file or directory
“无法打开图像papers/1375680721.pdf”:没有这样的文件或目录
if(!file_exists($pdf)){ echo noexists; return false; }
如果文件真不存在,过不了这个判断的
看看是不是文件权限问题,把papers/1375680721.pdf,权限设成777
看看是不是文件权限问题,把papers/1375680721.pdf,权限设成777 也不是权限问题,我怀疑是imagemagick有问题,我打开imagemagick把pdf文件丢进去,提示
if(!file_exists($pdf)) 只是检查了 $pdf 指向的文件是否存在
而你打开 pdf 的语句是 $im->readimage($pdf.[.$page.]);
显然 $pdf 和 $pdf.[.$page.] 不是一回事
你的这个写法是从哪里看来的?请给出出处!
我搜索到的相关代码中都没有见到这个写法
如果说 $pdf.[.$page.] 是表示 $pdf 的第 $page 也得话,那么若 $page 所表示的页不存在的话,是否也应该报错呢?
我没有 imagick 环境,无法测试。只是按常理推导
windows系统下运行,还需要装一个安装软件ghostscript;下载地址:http://downloads.ghostscript.com/public/gs904w32.exe ; 祝你成功。
'unable to open image `papers/1375680721. pdf': no such file or directory
“无法打开图像papers/1375680721.pdf”:没有这样的文件或目录
if(!file_exists($pdf)){ echo noexists; return false; }
如果文件真不存在,过不了这个判断的
要不,你看下这个帖子吧,好像也是类似的问题
http://stackoverflow.com/questions/4637251/unable-to-open-image-error-when-using-imagemagicks-filename-references