$img = preg_replace('/data:image\/(\w+);base64,/', '', $base64);
$img = preg_replace('/^data:image.*base64,/', '', $base64);