title: Imagick NoDecodeDelegateForThisImageFormat `PDF' @ error/constitute.c/ReadImage/509 while reading PDF in WAMP
body: <p>I have installed Imagick 3.4.4 in my WAMP using the steps defined here: <a href="https://newsinfo-blog.blogspot.com/2015/03/install-imagick-on-wamp-server.html" rel="nofollow noreferrer">https://newsinfo-blog.blogspot.com/2015/03/install-imagick-on-wamp-server.html</a> </p>
  
  <p>I then use the following code to convert a PDF to a JPEG image:</p>
  
  <pre><code>    $im = new Imagick();
  
      $im-&gt;setResolution(300,300);
      $im-&gt;readImage($_SERVER['DOCUMENT_ROOT'] . '/codeigniter/assets/lofthouse.pdf[0]');
      $im-&gt;setImageFormat('jpeg');
      $im-&gt;writeImage('thumblofthouse.jpg');
      $im-&gt;clear();
      $im-&gt;destroy();
  </code></pre>
  
  <p>But I am getting the following error message : </p>
  
  <blockquote>
    <p>An unknown error has occurred Type: ImagickException</p>
    
    <p>Message: NoDecodeDelegateForThisImageFormat `PDF' @
    error/constitute.c/ReadImage/509</p>
  </blockquote>
  
  <p>What am i doing wrong? How can I save the first page of a PDF as an image? </p>
  
  <p>I have noted that when I try : </p>
  
  <pre><code>print_r(Imagick::queryFormats());
  </code></pre>
  
  <p>the result is an empty array. </p>
  
  <p>EDIT:</p>
  
  <p>These are the steps I have undertaken so far:</p>
  
  <ol>
  <li>Downloaded ImageMagick <a href="https://imagemagick.org/script/download.php#windows" rel="nofollow noreferrer">https://imagemagick.org/script/download.php#windows</a> and installed it via the installer, put it in my D:\software folder.</li>
  <li>Downloaded &amp; installed Ghostscript : <a href="https://www.ghostscript.com/download/gsdnld.html" rel="nofollow noreferrer">https://www.ghostscript.com/download/gsdnld.html</a> , placed it in D:\ folder, and ticked the checkbox to generate the fonts. </li>
  <li>Copied the php_imagick.dll file to my /ext/ folder </li>
  <li>Copied over all the CORE_RL_* files to apache/bin/ folder</li>
  <li>Added the root path to the installation directory of ImageMagick in my PATH variables (and put it way above the PHP line)</li>
  </ol>
  
  <p>EDIT2:
  I've also done the following steps, although i'm definitely not sure whether these are needed</p>
  
  <ul>
  <li>Created a new system variable called MAGICK_HOME and let it point to the imagemagick root directory. </li>
  <li>modified the policy.xml in ImageMagick by adding <code>&lt;policy domain="module" pattern="{PS,PDF,XPS}" rights="read|write"/&gt;</code> in the policymap attribute. </li>
  </ul>
  
  <p>This is what phpinfo() returns: </p>
  
  <pre><code>imagick module  enabled
  imagick module version  3.4.4
  imagick classes Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
  Imagick compiled with ImageMagick version   ImageMagick 7.0.7-11 Q16 x86 2017-11-23 http://www.imagemagick.org
  Imagick using ImageMagick library version   ImageMagick 7.0.7-11 Q16 x86 2017-11-23 http://www.imagemagick.org
  ImageMagick copyright   Copyright (C) 1999-2015 ImageMagick Studio LLC
  ImageMagick release date    2017-11-23
  ImageMagick number of supported formats:    0
  </code></pre>
  
  <p>EDIT3: I am able to convert PDF to JPG via the commandline using ImageMagick. After all the steps above, i'm now getting the following error:</p>
  
  <pre><code>Type: ImagickException
  
  Message: no decode delegate for this image format `PDF' @ error/constitute.c/ReadImage/509
  </code></pre>