How to identify contents of a byte[] is a JPEG?

前端 未结 6 1805
没有蜡笔的小新
没有蜡笔的小新 2020-11-27 05:24

I have a small byte array (under 25K) that I receive and decode as part of a larger message envelope. Sometimes this is an image, furthermore it is a JPG. I have no context

6条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 05:25

    From wikipedia:

    JPEG image files begin with FF D8 and end with FF D9.

    http://en.wikipedia.org/wiki/Magic_number_(programming)

提交回复
热议问题