Search code examples
phpimagick

Imagick: unable to open file


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!


Solution

  • Use the full path to the image, for example:

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