Вам нужно будет декодировать данные base64, а затем прочитать их магию:
// read first 12 characters out of the base64 stream then decode
// to 9 characters. (9 should be sufficient for a magic)
$magic = base64_decode(substr($b64Img, 0, 12));
// determine file type
if (substr($magic, 0, 1) == 0xff &&
substr($magic, 1, 1) == 0xd8)
{
// jpg
}
else if (substr($magic, 0, 1) == 0x89 &&
substr($magic, 1, 5) == "PNG\r\n" &&
substr($magic, 6, 1) == 0x1a &&
substr($magic, 7, 1) == "\r")
{
// png
}
...