Format detection from the header
The tool reads the first few characters of the base64 string, which correspond to the binary file signature. PNG starts with 'iVBOR', JPEG with '/9j/', GIF with 'R0lG', and WebP with 'UklGR'. It uses these signatures to label the output format and MIME type. If the string has a data URI prefix, it may also parse the MIME type from that prefix.