iphonejpegimage-manipulationmagic-numbers

iPhone JPG image has non-standard magic bytes ff d8 ff e1?


My web app checks the first four bytes against the file extension before accepting uploaded images. A coworker showed me images from his iPhone which are being rejected. These have a different fourth byte (e1 = 225 instead of the expected e0 = 224).

Is this usual for iPhones? Are there other possible magic byte strings used in JPG files?

Edit: found this useful list: http://www.garykessler.net/library/file_sigs.html


Solution

  • They seem to indicate a sub category of JPEG in some way. What I have found out is that the FF D8 FF E0 magic indicates a "JFIF JPEG" whereas the FF D8 FF E1 indicates an "EXIF JPEG".

    Edit: Found this one in a google cache (interesting because it indicates that Samsung has a few more variations)