Imagick: unable to open file

Dzseti picture Dzseti · Mar 16, 2013 · Viewed 27.4k times · Source

When simply calling the Imagick class:

$image = new Imagick('/images/magick/atmsk.png');

I get the error message:

Fatal error: Uncaught exception 'ImagickException' with message 'unable to open file `/images/magick/atmsk.png' @ png.c/ReadPNGImage/2889' in .../imag.php:4 Stack trace: #0 .../imag.php(4): Imagick->__construct('/images/magick/...') #1 {main} thrown in .../imag.php

I have checked memory available as per another posting here and that is ok!

Answer

gmartellino picture gmartellino · Mar 16, 2013

Use the full path to the image, for example:

$image = new Imagick($_SERVER['DOCUMENT_ROOT'] . '/images/magick/atmsk.png');