User Tools

Site Tools


info:jpg_headers_explained

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
info:jpg_headers_explained [2009/04/23 14:54] – created tomgeeinfo:jpg_headers_explained [2009/04/23 14:55] (current) tomgee
Line 1: Line 1:
-JPEG Information+===== JPEG Information ===== 
  
 Digital Cameras save images in JFIF (usually incorrectly called JPEG or if you're an MS-DOS user JPG) format. Anyway, "JPEG" files consist of "markers" which separate out each part of the file. For example, every JPEG starts with a "start of image" marker and stop with an "end of image" marker. Most markers are followed by 2 bytes which tell the number of bytes that fit in the frame that was marked with this marker. After that the data follows. So what markers are in a typeical JPEG? These markers should exist in all JPEG files: Digital Cameras save images in JFIF (usually incorrectly called JPEG or if you're an MS-DOS user JPG) format. Anyway, "JPEG" files consist of "markers" which separate out each part of the file. For example, every JPEG starts with a "start of image" marker and stop with an "end of image" marker. Most markers are followed by 2 bytes which tell the number of bytes that fit in the frame that was marked with this marker. After that the data follows. So what markers are in a typeical JPEG? These markers should exist in all JPEG files:
  
-0xffd8 - Start Of Image +  * 0xffd8 - Start Of Image 
-0xfffe - Comment (Optional) +  0xfffe - Comment (Optional) 
-0xffdb - Quantization Table +  0xffdb - Quantization Table 
-0xffc0 - Start Of Frame (Baseline) +  0xffc0 - Start Of Frame (Baseline) 
-0xffc4 - Huffman Table (Sometimes ommited from mjpeg files) +  0xffc4 - Huffman Table (Sometimes ommited from mjpeg files) 
-0xffda - Start Of Scan (This is the actual compressed image) +  0xffda - Start Of Scan (This is the actual compressed image) 
-0xffd9 - End Of Image+  0xffd9 - End Of Image
  
 Why These Images Are Corrupt Why These Images Are Corrupt
Line 15: Line 16:
 So what's on a JPEG created by this camera: So what's on a JPEG created by this camera:
  
-0xffd8 - Start Of Image +  * 0xffd8 - Start Of Image 
-0xffe1 - Application Data +  0xffe1 - Application Data 
-0xffdb - Quantization Table +  0xffdb - Quantization Table 
-0xffc4 - Huffman Table +  0xffc4 - Huffman Table 
-0xffc0 - Start Of Frame (Baseline) +  0xffc0 - Start Of Frame (Baseline) 
-0xffda - Start Of Scan +  0xffda - Start Of Scan 
-0xffd9 - End Of Image+  0xffd9 - End Of Image
  
 This is all okay except for in the example file I used there are 8 extra padding bytes before the 0xffd9 and a bunch of extra garbage after the file. Actually, it seems to be padded by 11 bytes, but the IJG library only seems to complain about the 8 byte padding. I haven't seen another JPEG library that pads bytes tho. As far as the data at the end, I wonder what it looks like under a disassembler. I'm just glad I'm not using Windows or Internet Explorer to look at these images. This is all okay except for in the example file I used there are 8 extra padding bytes before the 0xffd9 and a bunch of extra garbage after the file. Actually, it seems to be padded by 11 bytes, but the IJG library only seems to complain about the 8 byte padding. I haven't seen another JPEG library that pads bytes tho. As far as the data at the end, I wonder what it looks like under a disassembler. I'm just glad I'm not using Windows or Internet Explorer to look at these images.
info/jpg_headers_explained.1240512855.txt.gz · Last modified: 2009/04/23 14:54 by tomgee