JPEG image in base64 format

后端 未结 1 1101
走了就别回头了
走了就别回头了 2021-01-13 12:04

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

1条回答
  •  南笙
    南笙 (楼主)
    2021-01-13 12:48

    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

    0 讨论(0)
提交回复
热议问题