-3

If you open a *.gif file with notepad the file starts with GIF89

but for the *.jpeg files the first characters aren't something like GIF89

How can I detect that my file is *.jpeg with it's file first characters?

Drew Dormann
  • 59,987
  • 13
  • 123
  • 180
user3105142
  • 13
  • 2
  • 6

1 Answers1

5

According to The JPEG File Interchange Format:

  • (After a 2 byte "SOI" marker...)
  • the next 2 bytes will be 0xFFE0
  • the next 2 bytes are unimportant for this detection
  • the next 5 bytes will be "JFIF" (including the null-terminator)
Drew Dormann
  • 59,987
  • 13
  • 123
  • 180