Why is it returning exit status 11?
<pre><code>&lt;?php
require_once 'functions.php';
if(!isset($_SERVER['DOCUMENT_ROOT'])){
  $_SERVER['DOCUMENT_ROOT'] = /* ... */;
}

if(isset($_GET['img'])){
  $id = urldecode($_GET['img']);
}else{
  die('unspecified');
}

$w = 150;
$h = 114;

$row = get_fields($id, array('name', 'ext'));
$image = $_SERVER['DOCUMENT_ROOT'] . '/images/' . $row['name'];

if (!file_exists($image)){
  die('invalid');
}
$cache = $_SERVER['DOCUMENT_ROOT'] . '/thumbs/' . $row['name'];
$cli = isset($_GET['context']) &amp;&amp; $_GET['context'] == 'cli';

if(!file_exists($cache)){
  $thumb = cacheThumb($image);
}elseif(!$cli){
  $thumb = new Imagick($cache);
}

if(!$cli){
  header ('Content-Type: image/' . strtolower($thumb-&gt;getImageFormat()));
  echo $thumb-&gt;getImageBlob();
}else{
  exit(0);
}

function cacheThumb($image){
  global $cache, $w, $h, $firephp;
  $thumb = new Imagick($image);
  $thumb-&gt;flattenImages();
  $quotient = min($thumb-&gt;getImageWidth() / $w,
                  $thumb-&gt;getImageHeight() / $h);
  $thumb-&gt;cropImage($w * $quotient, $h * $quotient, 0, 0);
  $thumb-&gt;scaleImage($w, $h);
  $thumb-&gt;writeImage($cache);
  return $thumb;
}

?&gt;
</code></pre>
