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) 200527-uncode-jpeg.tgz (ca. 110 kB)

There are lots of unsupported JPEG markers. In the new version (27th of Mai) Table indices are handled correctly. In the new version you can write a stripped version of the file with -o NEWFILE.jpg. (Works only with few files.)

This tool helps with getting an overview over a arbitrary JPEG file.

The program output looks like this:


Opening file Bilder/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
Scanning through additional 7617 bytes which are non-consumed yet ...
Marker   2a @0x   f8c +1         : SOI  Start Of Image
Marker   2b @0x   f8e -> 0x  1014: DQT  Define Quantization Table(s) q0, 64x1 B
                                                                     q1, 64x1 B
Marker   2c @0x  1014 -> 0x  11b8: DHT  Define Huffman Table(s) ID 00, #cp:  12
                                                                ID 01, #cp:  12
                                                                ID 10, #cp: 162
                                                                ID 11, #cp: 162
Marker   2d @0x  11b8 -> 0x  11cb: SOF0 Start Of Frame (0 - baseline DCT)
   prec  8, size  160 x  120, component  1: sampling fact. 0x21, table q0
                              component  2: sampling fact. 0x11, table q1
                              component  3: sampling fact. 0x11, table q1
Marker   2e @0x  11cb -> 0x  11d9: SOS  Start Of Scan
                              component  1: huffman tables: ID 00 DC, ID 10 AC
                              component  2: huffman tables: ID 01 DC, ID 11 AC
                              component  3: huffman tables: ID 01 DC, ID 11 AC
                              further flags: 0x00 0x3f 0x00
Marker   2f @0x  1dd5 +1         : EOI  End Of Image
... scanning done
Marker   3  @0x  1dd7 +1         : invalid - ffe3 was not exptected here
Marker   4  @0x  1dd9 +1         : invalid - ffff was not exptected here
Marker   5  @0x  1ddb +1         : SOI  Start Of Image
Marker   6  @0x  1ddd -> 0x  1e63: DQT  Define Quantization Table(s) q0, 64x1 B
                                                                     q1, 64x1 B
Marker   7  @0x  1e63 -> 0x  2007: DHT  Define Huffman Table(s) ID 00, #cp:  12
                                                                ID 01, #cp:  12
                                                                ID 10, #cp: 162
                                                                ID 11, #cp: 162
Marker   8  @0x  2007 -> 0x  201a: SOF0 Start Of Frame (0 - baseline DCT)
   prec  8, size  640 x  480, component  1: sampling fact. 0x21, table q0
                              component  2: sampling fact. 0x11, table q1
                              component  3: sampling fact. 0x11, table q1
Marker   9  @0x  201a -> 0x  2028: SOS  Start Of Scan
                              component  1: huffman tables: ID 00 DC, ID 10 AC
                              component  2: huffman tables: ID 01 DC, ID 11 AC
                              component  3: huffman tables: ID 01 DC, ID 11 AC
                              further flags: 0x00 0x3f 0x00
Marker  10  @0x 11dd8 +1         : invalid - ffe4 was not exptected here
Marker  11  @0x 1ab5d +1         : EOI  End Of Image
Marker  12  @0x 1ab5f -> 0x 1abe5: DQT  Define Quantization Table(s) q0, 64x1 B
                                                                     q1, 64x1 B
Marker  13  @0x 1abe5 -> 0x 1ad89: DHT  Define Huffman Table(s) ID 00, #cp:  12
                                                                ID 01, #cp:  12
                                                                ID 10, #cp: 162
                                                                ID 11, #cp: 162
Marker  14  @0x 1ad89 -> 0x 1ad9c: SOF0 Start Of Frame (0 - baseline DCT)
   prec  8, size 3648 x 2736, component  1: sampling fact. 0x21, table q0
                              component  2: sampling fact. 0x11, table q1
                              component  3: sampling fact. 0x11, table q1
Marker  15  @0x 1ad9c -> 0x 1adaa: SOS  Start Of Scan
                              component  1: huffman tables: ID 00 DC, ID 10 AC
                              component  2: huffman tables: ID 01 DC, ID 11 AC
                              component  3: huffman tables: ID 01 DC, ID 11 AC
                              further flags: 0x00 0x3f 0x00
Marker  16  @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-11; marker 1+12-16 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) q0, 64x1 B
                                                                     q1, 64x1 B
Marker   3  @0x    88 -> 0x   22c: DHT  Define Huffman Table(s) ID 00, #cp:  12
                                                                ID 01, #cp:  12
                                                                ID 10, #cp: 162
                                                                ID 11, #cp: 162
Marker   4  @0x   22c -> 0x   23f: SOF0 Start Of Frame (0 - baseline DCT)
   prec  8, size 3648 x 2736, component  1: sampling fact. 0x21, table q0
                              component  2: sampling fact. 0x11, table q1
                              component  3: sampling fact. 0x11, table q1
Marker   5  @0x   23f -> 0x   24d: SOS  Start Of Scan
                              component  1: huffman tables: ID 00 DC, ID 10 AC
                              component  2: huffman tables: ID 01 DC, ID 11 AC
                              component  3: huffman tables: ID 01 DC, ID 11 AC
                              further flags: 0x00 0x3f 0x00
Marker   6  @0x286322 +1         : EOI  End Of Image
End of file reached.

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

Hintergrundbild: Schräge Vorderansicht der Lok 1142.562-9