0

I have a file of bytes that represent a .jpeg image. However, when I try to open the image, I get an error that indicates my file is of incorrect format. I'm a little thrown off by this as the bytes in the file look like they should work. In what I've read, the file lines up with the JPEG file format exactly. It's a decent sized image, so I won't post all the data, but the first couple lines look like this:

ff d8 ff e0 00 10 4a 46 49 46 00 01 01 00 00 01 00 01 00 00 ff e1 00 58 45 78 69 66 00 00 4d 4d 00 2a 00 00 00 08 00 02 01 12 00 03 00 00 00 01 00 06 00 00 87 69 00 04 00 00 00 01 00 00 00 26 00 00 00 00 00 03 a0 01 00 03 00 00 00 01 00 01 00 00 a0 02 00 04 00 00 00 01 00 00 0a 20 a0 03 00 04 00 00 00 01 00 00 07 90 00 00 00 00 ff db 00 43 00 1f 15 17 1b 17 13 1f 1b 19 1b 23 21 1f 25 2f 4e 32 2f

I've looked at the source for some other .jpeg images and I can tell it differs drastically from what I have here. I suspect there is some encoding going on, I'm just not sure what it is. If someone could point me in the right direction I would be very grateful. Thanks!

Edit

This is the hex data for the file. I know I need to convert it into something. I'm just not sure what. Is it decimal, binary, or what? Thanks!

NSchulze
  • 179
  • 1
  • 5
  • 19
  • If it was a real jpeg file, it'd have JFIF in the first few characters. Unless you've converted those yourself, you've got a text file showing the hex values of each byte in the original jpeg file instead. – Marc B Sep 24 '12 at 04:48
  • Is there anything I can do with that to turn it into an actual jpeg? – NSchulze Sep 24 '12 at 04:51
  • have you tested it with some jpeg tester tools like [this one] (http://www.softpedia.com/get/Multimedia/Graphic/Digital-Photo-Tools/IT-JPEG-Tester.shtml)? – RGO Sep 24 '12 at 04:52
  • are you saying that your file has these characters in it or that you copied them from a binary/hex editor? When you open in Notepad, do you see "ff d8 ff e0 00" ... The "4a 46 49 46" is the JFIF, so this might be a jpeg if you convert the text to a binary file with the same bytes. – Lou Franco Sep 24 '12 at 20:16
  • JPEG images are not required to have an APP0 marker with JFIF in it. Please post a link to the file and I'll tell you what's wrong with it. – BitBank Sep 24 '12 at 20:21
  • The ff d8 ff e0 00.. is what I see when I look at it in a text editor. I'm just not sure what I need to convert the bytes to. – NSchulze Sep 25 '12 at 04:27

2 Answers2

0

If you are saying you literally have hex digits in a text file that represent a binary -- you can convert it with this tool: http://stahlworks.com/dev/index.php?tool=hextobin

Or you could write a program yourself. If you add some info on a language you know, someone might point you in the right direction. Here is an implementation in Perl http://www.velocityreviews.com/forums/t22256-hexadecimal-to-binary-file-conversion-utility.html

Lou Franco
  • 87,846
  • 14
  • 132
  • 192
0

You should definitely use JPEGsnoop that is a tool dedicated to (among others) inspecting JPEG files - including Error Detection in Corrupt JPEG Photos (see JPEGsnoop uses).

From what you have posted, the first 20 bytes are perfectly correct (including a valid SOI marker 0xFFD8, APP0 marker 0xFFE0, segment length 0x0010, etc). JPEGsnoop will help identifying what's wrong.

deltheil
  • 15,496
  • 2
  • 44
  • 64