PHP imagick library for pdf processing
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): 1272png ('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
The following error is reported:
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;}
Reply to discussion (solution)
He makes it clear that papers/1375680721.pdf does not exist.
He makes it clear that papers/1375680721.pdf does not exist because the file exists.
'Unable to open image' papers/1375680721.pdf ': No such file or directory
"Unable to open Image papers/1375680721.pdf": there is no such file or directory
'Unable to open image' papers/1375680721.pdf ': No such file or directory
"Unable to open Image papers/1375680721.pdf": there is no such file or directory
@ Error/blob. c/OpenBlob/2622 'what does this error mean?
'Unable to open image' papers/1375680721.pdf ': No such file or directory
"Unable to open Image papers/1375680721.pdf": there is no such file or directory
If (! File_exists ($ PDF) {echo "noexists"; return false ;}
If the file does not exist, you cannot pass this judgment.
Check whether the file permission is correct. set papers/1375680721.133 to 777.
Check whether the file permission is correct. setting the papers/1375680721.133 permission to 777 is not a Permission Problem. I suspect there is a problem with imagemagick. I opened imagemagick and threw the PDF file in, prompting
If (! File_exists ($ PDF) only checks whether the file pointed to by $ PDF exists.
The statement you open in pdf is $ IM-> readImage ($ PDF. "[". $ page. "]");
Obviously, $ PDF and $ PDF. "[". $ page. "]" are not the same thing.
Where does your writing look like this? Please provide the source!
I have not found this method in the searched code.
If you say $ PDF. "[". $ page. "]" indicates the $ page of $ PDF. if $ page does not exist, should we report an error?
I have no imagick environment and cannot test it. Just according to common sense
Run in Windows, you also need to install a software ghostscript;: http://downloads.ghostscript.com/public/gs904w32.exe; wish you success.
'Unable to open image' papers/1375680721. pdf ': No such file or directory
"Unable to open Image papers/1375680721.pdf": there is no such file or directory
If (! File_exists ($ PDF) {echo "noexists"; return false ;}
If the file does not exist, you cannot pass this judgment.
Otherwise, you can read this post. it seems similar.
Http://stackoverflow.com/questions/4637251/unable-to-open-image-error-when-using-imagemagicks-filename-references