title: How to use PHP drawing functions with Laravel
body: <p>I'm trying to use PHP shape drawing functions with the Laravel framework but I am having some trouble.</p>
  
  <p>So, I just to test it out, basically just copied the example from php.net and used it in a closure and a test route.</p>
  
  <pre><code>Route::get('maptest', function()
  {
  $image = imagecreatetruecolor(200, 200);
  $red = imagecolorallocate($image, 227, 32, 32);
  
  imagefilledrectangle($image, 100, 80, 50, 25, $red);
  
  header('Content-Type: image/png');
  
  imagepng($image);
  imagedestroy($image);
  });
  </code></pre>
  
  <p>doing it this way works fine.</p>
  
  <p>the problem is when I throw a <code>Controller</code> and a <code>View</code> into the mix. When I set the headers and what not and create a <code>Response</code>, I get a little broken picture icon in the top left corner of the window and nothing on the page loads at all.</p>
  
  <p>this is how I am setting the headers.
  (I know this is posted everywhere, but none of the solutions I could find seemed to work for me.)</p>
  
  <pre><code>public function show($id)
  {
      $user = User::find($id);
  
      $view = View::make('profile/home', ['user' =&gt; $user]);
  
      $response = Response::make($view, 200);
      $response-&gt;header('Content-type', 'image/png');
  
      return $response;
  }
  </code></pre>
  
  <p>So the result of the above code (inside my controller) gives me a little broken picture icon in top left corner of window.</p>