title: imagecreatefromstring(): Data is not in a recognized format in
body: <p>Here is how I get my image:</p>
  
  <pre><code>$coverurl  = 'https://api.someurl/api/v1/img/' . $somenumber . '/l';
  //$iheaders contains: 'Content-type' =&gt; 'image/jpeg'
  $iresponse = wp_remote_get($coverurl, $iheaders);
  $img = $iresponse['body'];
  $testimg = base64_encode($img);
  </code></pre>
  
  <p>When I echo $testimg with an img-tag, everything works fine.</p>
  
  <pre><code>echo '&lt;img class="attachment-shop_single size-shop_single wp-post-image" src="data:image/jpeg;base64,'.$testimg.'" width="274" /&gt;';
  </code></pre>
  
  <p>Since I need to convert the string into a jpg and save it to my uploads folder, I tried to use <code>imagecreatefromstring()</code>.</p>
  
  <pre><code>$imgx = imagecreatefromstring($testimg);
          if ($imgx !== false) {
              header('Content-Type: image/jpeg');
              imagejpeg($imgx);
              imagedestroy($imgx);
          } else {
              echo 'An error occurred.';
          }
  </code></pre>
  
  <p>But I never get to the point of saving anything, because of the following warning:</p>
  
  <pre><code> Warning: imagecreatefromstring(): Data is not in a recognized format in /etc.
  </code></pre>
  
  <p>When I echo <code>$testimg</code> I get:</p>
  
  <pre><code>/9j/4AAQSkZJRgABAQAAAQABAAD ...Many number and characters.. Ggm2JUsEvfqnxAhGFDP/9k=
  </code></pre>
  
  <p>What must I do to make <code>createimagefromstring</code> work? Do I have to modify the <code>$testimg</code> string? Thanks for your interest.</p>