Failed to open file

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
Irhak
Posts: 3
Joined: 2018-10-01T03:42:43-07:00
Authentication code: 1152

Failed to open file

Post by Irhak »

Hi! I don't know if I write to right thread.

I have installed ImagickMagick 6 on Debian Jessie (and also Wheezy) through apt-get. Using imagick function I was able to create jpg version of pdfs till last month. Today I stamble upon a problem with this. Every time I try to use it to create jpg from pdf I error "Failed to open file" pop-up, even when I'm using old pdfs that worked before. Pdfs are opening normally (outside scripts that using imagick) without any problem. With jpegs there are no problems, imagick->readImage($dest) read file without any issues.

There was no updates made in last few weeks so no new code could affect it. Especially that last week it worked fine.

Here is a fragment of the code I use:

Code: Select all

$image = new imagick();
$image->setResolution(300, 300);
$image->readImage($dest);
$image->setImageFormat('jpg');
$image->writeImage($preview);
$image->clear();
$image->destroy();
Is the file path an issue suddenly (e.g. /var/www/userfiles/1/ads/2018-09/GRAFFI-STUDIO-7640.pdf)? or maybe there was some date inside imagick or ghostscript that make it expired?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Failed to open file

Post by fmw42 »

Try moving the file to some other directory? Perhaps there is some permission issue. If you download the file, can you open it? Has it become corrupt?
Irhak
Posts: 3
Joined: 2018-10-01T03:42:43-07:00
Authentication code: 1152

Re: Failed to open file

Post by Irhak »

PDF is fine. I can open it without any errors. Imagick can't read any pdf file - neither new or the old that was already processed. It all started yesterday.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Failed to open file

Post by magick »

From the command line, type

Code: Select all

convert mypdf.pdf null:
Do you get an authorization exception? If so, check your system policy.xml configuration file. There is a policy that prevents ImageMagick from reading PDF files. See https://www.imagemagick.org/script/security-policy.php.
Irhak
Posts: 3
Joined: 2018-10-01T03:42:43-07:00
Authentication code: 1152

Re: Failed to open file

Post by Irhak »

Weirdest thing ever. I left the problem for some time and after that the problem was gone. Looks like it is safe now. Problem left same as it come - unexcpected.
Post Reply