title: force download image as response lumen + intervention image
body: <p>I'm using <a href="http://image.intervention.io" rel="nofollow noreferrer">intervention image</a> on my Lumen project and everything works until I come across on making the encoded image as a downloadable response which upon form submit that contains the image file that will be formatted unto specific format e.g. webp, jpg, png will be sent back as a downloadable file to the user, below is my attempt.</p>
  
  <pre><code>public function image_format(Request $request){
      $this-&gt;validate($request, [
          'image' =&gt; 'required|file',
      ]);
  
      $raw_img = $request-&gt;file('image');
  
      $q = (int)$request-&gt;input('quality',100);
      $f = $request-&gt;input('format','jpg');
  
      $img = Image::make($raw_img-&gt;getRealPath())-&gt;encode('webp',$q);
  
      header('Content-Type: image/webp');
  
      echo $img;
  }
  </code></pre>
  
  <p>but unfortunately, its not my expected output, it just did display the image.</p>
  
  <p>from this <a href="https://stackoverflow.com/questions/48402655/laravel-lumen-file-response">post</a>, I use the code and attempt to achieve my objective</p>
  
  <pre><code>public function image_format(Request $request){
          $this-&gt;validate($request, [
              'image' =&gt; 'required|file',
          ]);
  
          $raw_img = $request-&gt;file('image');
  
          $q = (int)$request-&gt;input('quality',100);
          $f = $request-&gt;input('format','jpg');
  
          $img = Image::make($raw_img-&gt;getRealPath())-&gt;encode('webp',$q);
          $headers = [
              'Content-Type' =&gt; 'image/webp',
              'Content-Disposition' =&gt; 'attachment; filename='. $raw_img-&gt;getClientOriginalName().'.webp',
          ];
  
          $response = new BinaryFileResponse($img, 200 , $headers);
          return $response;
      }
  </code></pre>
  
  <p>but its not working, instead it showed me this error</p>
  
  <p><a href="https://i.stack.imgur.com/E9lsu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E9lsu.png" alt="enter image description here"></a></p>
  
  <p>any help, ideas please?</p>