title: How to convert guzzle response (from image url) to base64
body: <p>I try to download image with guzzle and then convert the response to base64 without storing in local path.
  In my project I have a function to get the response from guzzle, with below code, and then I want to know how can I convert the response <code>$body</code> to a base64 string.</p>
  
  <pre class="lang-php prettyprint-override"><code>$response = $this-&gt;client-&gt;request(
      $req_type,
      $Url,
      [
          'body' =&gt; $post_data,
          'connect_timeout' =&gt; $TimeOut,
          'verify' =&gt; false,
          //'debug' =&gt; $debug,
          'cookies' =&gt; $cookiejarlocal,
      ]
  );
  
  $body = $response-&gt;getBody();
  </code></pre>