title: Detecting image type from base64 string in PHP
body: <p>Is it possible to find out the type of an image encoded as a base64 String in PHP? </p>
  
  <p>I have no method of accessing the original image file, just the encoded string. From what I've seen, <code>imagecreatefromstring()</code> can create an image resource from a string representation (after it's been decoded from base64), but it automatically detects the image type and the image resource itself is a special PHP representation. In case I want to save the image as a file again, I would have no idea if the type I am saving it as corresponds to the original type from which the String representation was created.</p>