uncode-jpeg: Makes the sections of jpeg files visible

Download

Here's the source, together with the compiled binary and a sample image from Wikipedia: 200510-uncode-jpeg.tgz (ca. 100 kB)

There are lots of unsupported JPEG markers and the indices to the Huffman tables are print in a wrong way, but this tool helps anyway for getting an overview.

The program output looks like this:


Opening file SDC16414x.jpg .
Marker #  1 @0x     0 +1         : SOI  Start Of Image
Marker #  2 @0x     2 -> 0x  1dd7: APPn Application-specific (1 - EXIF/XMP)
   EXIF metadata
   interoperability number = hex 0B 00
Marker #  3 @0x   f8c +1         : SOI  Start Of Image
Marker #  4 @0x   f8e -> 0x  1014: DQT  Define Quantization Table(s)
Marker #  5 @0x  1014 -> 0x  11b8: DHT  Define Huffman Table(s)
Marker #  6 @0x  11b8 -> 0x  11cb: SOF0 Start Of Frame (0 - baseline DCT)
   prec  8, size  160 x  120, component  1: sampling fact. 0x21, quant. tbl 0
                              component  2: sampling fact. 0x11, quant. tbl 1
                              component  3: sampling fact. 0x11, quant. tbl 1
Marker #  7 @0x  11cb -> 0x  11d9: SOS  Start Of Scan
                              component  1: no hufmann tbl
                              component  2:    huffman tbl 0x11
                              component  3:    huffman tbl 0x11
                              further bytes: 0x00 0x3f 0x00
Marker #  8 @0x  1dd5 +1         : EOI  End Of Image
Marker #  9 @0x  1dd7 +1         : invalid - ffe3 was not exptected here
Marker # 10 @0x  1dd9 +1         : invalid - ffff was not exptected here
Marker # 11 @0x  1ddb +1         : SOI  Start Of Image
Marker # 12 @0x  1ddd -> 0x  1e63: DQT  Define Quantization Table(s)
Marker # 13 @0x  1e63 -> 0x  2007: DHT  Define Huffman Table(s)
Marker # 14 @0x  2007 -> 0x  201a: SOF0 Start Of Frame (0 - baseline DCT)
   prec  8, size  640 x  480, component  1: sampling fact. 0x21, quant. tbl 0
                              component  2: sampling fact. 0x11, quant. tbl 1
                              component  3: sampling fact. 0x11, quant. tbl 1
Marker # 15 @0x  201a -> 0x  2028: SOS  Start Of Scan
                              component  1: no hufmann tbl
                              component  2:    huffman tbl 0x11
                              component  3:    huffman tbl 0x11
                              further bytes: 0x00 0x3f 0x00
Marker # 16 @0x 11dd8 +1         : invalid - ffe4 was not exptected here
Marker # 17 @0x 1ab5d +1         : EOI  End Of Image
Marker # 18 @0x 1ab5f -> 0x 1abe5: DQT  Define Quantization Table(s)
Marker # 19 @0x 1abe5 -> 0x 1ad89: DHT  Define Huffman Table(s)
Marker # 20 @0x 1ad89 -> 0x 1ad9c: SOF0 Start Of Frame (0 - baseline DCT)
   prec  8, size 3648 x 2736, component  1: sampling fact. 0x21, quant. tbl 0
                              component  2: sampling fact. 0x11, quant. tbl 1
                              component  3: sampling fact. 0x11, quant. tbl 1
Marker # 21 @0x 1ad9c -> 0x 1adaa: SOS  Start Of Scan
                              component  1: no hufmann tbl
                              component  2:    huffman tbl 0x11
                              component  3:    huffman tbl 0x11
                              further bytes: 0x00 0x3f 0x00
Marker # 22 @0x2a0e7f +1         : EOI  End Of Image
End of file reached.


Remark: this is not the sample file you find in archive!

This is a baseline jpeg file (on slow connections renders visibly from top to bottom). In contrast, a progressive jpeg file would be blurred in the beginning and get sharper till the end of the transmission.

You can delete all contents of markers 2-17; marker 1+18-22 do contain the actual image.

After invoking exiftool -APP3:all= -EXIF:all= -APP4:all= SDC16414x.jpg the file looks like this (and is more than 5% smaller):


Opening file SDC16414x.jpg .
Marker #  1 @0x     0 +1         : SOI  Start Of Image
Marker #  2 @0x     2 -> 0x    88: DQT  Define Quantization Table(s)
Marker #  3 @0x    88 -> 0x   22c: DHT  Define Huffman Table(s)
Marker #  4 @0x   22c -> 0x   23f: SOF0 Start Of Frame (0 - baseline DCT)
   prec  8, size 3648 x 2736, component  1: sampling fact. 0x21, quant. tbl 0
                              component  2: sampling fact. 0x11, quant. tbl 1
                              component  3: sampling fact. 0x11, quant. tbl 1
Marker #  5 @0x   23f -> 0x   24d: SOS  Start Of Scan
                              component  1: no hufmann tbl
                              component  2:    huffman tbl 0x11
                              component  3:    huffman tbl 0x11
                              further bytes: 0x00 0x3f 0x00
Marker #  6 @0x286322 +1         : EOI  End Of Image
End of file reached.


Document of May 10, 2020, last modification on 10 May 2020. Page source

Hintergrundbild: Schräge Vorderansicht der Lok 1142.562-9