PHP Imagick Library handling PDF issues

Source: Internet
Author: User
Tags imagemagick
Php

Fatal error:uncaught exception ' imagickexception ' with message ' Unable to open image ' Papers/1375680721.pdf ': No such fil E or directory @ error/blob.c/openblob/2622 ' in c:\xampp\htdocs\fc\editpaper.php:38 Stack trace: #0
C:\xampp\htdocs\fc\editpaper.php: 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

Report the following error
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 (+);   $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's clear, papers/1375680721.pdf doesn't exist.

He's clear, papers/1375680721.pdf doesn't exist, not for this reason, the file exists.

' Unable to open image ' Papers/1375680721.pdf ': No such file or directory
"Unable to open image Papers/1375680721.pdf": No such file or directory

' Unable to open image ' Papers/1375680721.pdf ': No such file or directory
"Unable to open image Papers/1375680721.pdf": 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": No such file or directory
if (!file_exists ($PDF)) {echo "noexists"; return false;}
If the file doesn't exist, it's not going to be a good decision.

See if it's a file permission issue, set the Papers/1375680721.pdf, permissions to 777.

To see if the file permissions issue, the Papers/1375680721.pdf, the permissions set to 777 is not a permission issue, I suspect that ImageMagick has a problem, I opened the ImageMagick to put the pdf file in, prompted

if (!file_exists ($PDF)) just checks to see if the file that the $PDF points to exists
And the statement you open the PDF is $IM->readimage ($PDF. " [". $page."] ");
Obviously $PDF and $PDF. " [". $page."] Not the same thing
Where does this writing look from? Please give the source!
I didn't see it in the code I was searching for.
If you say $PDF. " [". $page."] is to say that the $PDF of the first $page also have the words, then if the $page the page indicated does not exist, should also be an error?

I do not have imagick environment, cannot test. Just a commonsense deduction.

Windows system running, also need to install a software ghostscript; Download address: Http://downloads.ghostscript.com/public/gs904w32.exe; I wish you success.



' Unable to open image ' papers/1375680721. PDF ': No such file or directory
"Unable to open image Papers/1375680721.pdf": No such file or directory
if (!file_exists ($PDF)) {echo "noexists"; return false;}
If the file doesn't exist, it's not going to be a good decision.

Otherwise, you look at this post, it seems to be a similar problem

Http://stackoverflow.com/questions/4637251/unable-to-open-image-error-when-using-imagemagicks-filename-references

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.