title: How to encode an image resource to base64?
body: <p>I was wondering if there's a way to encode an image to a base64 if it was a resource
  for example if I loaded an image using GD</p>
  
  <pre><code>    $image = imagecreatefromjpeg("captcha/$captcha-$num.jpg");
  
      // Add some filters
      imagefilter($image, IMG_FILTER_PIXELATE, 1, true);
      imagefilter($image, IMG_FILTER_MEAN_REMOVAL);
  </code></pre>
  
  <p>If this was my code and instead of saving the image and displaying it using</p>
  
  <pre><code>&lt;img src='someimage.jpg'&gt;
  </code></pre>
  
  <p>I wanted to display it as a data URI without having to save it, like</p>
  
  <pre><code>&lt;img data='src="data:image/jpeg;base64,BASE64_HERE'&gt;
  </code></pre>
  
  <p>How can I do that?</p>