I have a camera that send me an xml file with some tags , including a tag that represents the image in base64 format. The image is in JPEG format.
For some reason th
Jpeg file format (as many others) can be identified by magic number. For JPEG the magic number is ff d8 ff
at offset 0
. If you encode this to Base64, you'll always get /9j/
.
Additional note: since Base64 converts group of 3 data bytes to 4 bytes (ASCII), this will work for any magic number with length and offset multiple of 3 bytes. If the length of magic number is not multiple of 3, the last group of 4 Base-64 encoded characters will change depending on the data immediately following the magic number.
https://en.wikipedia.org/wiki/JPEG
https://en.wikipedia.org/wiki/List_of_file_signatures