The most easiest way is to deal it with the preg_match if it matches the base 64 data url pattern you can easily get image type
`preg_match('/^data:(image\/\w+);base64,/', $dataUrl, $matches)
$imageType = $matches[1];`
using this regex you will get image type in $imageType