title: Imagick error Uncaught ImagickException: Can not process empty Imagick object
body: <pre><code>&lt;?php
  error_reporting(E_ALL);
  ini_set('display_errors', 'On');
  
  /* The object used as a canvas */
  $canvas = new imagick( &quot;fake_wood_plastic_formica_4131428.jpg&quot; );
  $canvas-&gt;adaptiveResizeImage( 300, 300 );
  $canvas-&gt;setImageFormat( &quot;png&quot; );
   
  /* paths to the images */
  $paths = array( &quot;chev7.jpg&quot;, &quot;myfrog.jpg&quot;, &quot;strawberry.jpg&quot;, &quot;Image32.jpg&quot; );
   
  /* Create an empty ImagickDraw object
      (Use the defaults for the polaroid) */
  $bg = new ImagickDraw();
   
  /* Create a few random images */
  $images = new Imagick( $paths );
   
  /* Loop trough images, overlay on canvas and remove the image */
  foreach ( $images as $key =&gt; $image )
  {
      /* Thumbnail to 100x width and set background to black.
              It looks like an drop-in shadow :) */
      $image-&gt;thumbnailImage( 100, null );
      $image-&gt;setImageBackgroundColor( new ImagickPixel( &quot;black&quot; ) );
     
      /* Use a random angle */
      $angle = mt_rand( 1, 45 );
   
      if ( mt_rand( 1, 2 ) % 2 === 0 )
      {   
          $angle = $angle * -1;
      }
   
      /* Create the polaroid */
      $image-&gt;polaroidImage( $bg, $angle );
   
      /* Composite the polaroid over the canvas */
   
          /* Composite to a random location */
      $canvas-&gt;compositeImage( $image, Imagick::COMPOSITE_OVER,
                                 mt_rand( 10, 150 ), mt_rand( 10, 150 ) );
     
      /* Free some resources */
      $image-&gt;removeImage();
  }
   
  /* Display the image */
  header( &quot;Content-Type: image/png&quot; );
  echo $canvas;
  
   
  ?&gt;
  </code></pre>
  <p>error: Fatal error: Uncaught ImagickException: Can not process empty Imagick object in /home/kpsspuan/public_html/twitter/save.php:22 Stack trace: #0 /home/kpsspuan/public_html/twitter/save.php(22): Imagick-&gt;valid() #1 {main} thrown in /home/kpsspuan/public_html/twitter/save.php on line 22</p>