title: How to convert a Base64 PNG to a JPG image?
body: <p>I have this Base64 PNG, which I want to decode to JPG. If I convert to PNG it works fine, using: </p>
  
  <pre><code>list($type, $data) = explode(';', $data);
  list(, $data)      = explode(',', $data);
  $data = base64_decode($data);
  file_put_contents('myDirectory/filename.png', $data);
  </code></pre>
  
  <p>But if I try to save it as JPG, it comes out in black and white using (<code>MyDirectory/filename.jpg</code>).</p>
  
  <p>How do I convert it to a JPG? here is an example of my Base64 PNG:</p>
  
  <pre><code>data:image/png;base64,iVBORw0KGgoAAAANSUhE...
  </code></pre>