As I understand it, you can figure-out where the follow-up EOI marker is after the scan-data by seeking through it and skipping FFD0 to FFD7 and any FFFF's (escaped/compressed FF), and then just stopping when you hit another marker (which should always be an EOI (FFD9)?).
However, I ran into the following:
003f24d0 ce 51 1b 12 f9 fb a4 1f bb 40 8f ff d9 00 a8 eb |.Q.......@......|
003f24e0 2a 83 a7 2a |*..*|
There is an FFD9 but this isn't at the end of the file, nor is it preceded by FF (so it's definitely not an FF byte that was compressed/escaped), nor is it followed by another marker (00 rather than FF) so this isn't some [obvious] mistake.
The file actually ends with an FFD9 (as expected), but when I truncate the file to just after the first FFD9, the image still opens and looks normal. Does anyone know the file-format that I'm dealing with? It seems like there are multiple EOI's separated by undefined data (as far as JPEG goes).
What I find interesting is that I have two images from the same camera that seem to be identical (aside from scan-data), but yet only one has this extra data.
Looks good:
$ file "IMG_6694.JPG"
IMG_6694.JPG: JPEG image data, Exif standard: [TIFF image data, little-endian, direntries=11, description= , manufacturer=Canon, model=Canon PowerShot SX720 HS, orientation=upper-left, xresolution=210, yresolution=218, resolutionunit=2, datetime=2016:09:24 07:32:29, GPS-Data], baseline, precision 8, 5184x2912, frames 3
$ ./js_dump -f "IMG_6694.JPG"
0x00000002 0xd8 [SOI]
0x00007002 0xe1 [APP1]
0x00007fa0 0xe1 [APP1]
0x00008002 0xe2 [APP2]
0x00008088 0xdb [DQT]
0x0000809b 0xc0 [SOF0]
0x0000823f 0xc4 [DHT]
0x00008241 0xda [SOS]
0x0032d9bb 0x00 [!SCANDATA]
0x0032d9bd 0xd9 [EOI]
Has the extra EOIs:
$ file "IMG_6691.JPG"
IMG_6691.JPG: JPEG image data, Exif standard: [TIFF image data, little-endian, direntries=11, description= , manufacturer=Canon, model=Canon PowerShot SX720 HS, orientation=upper-left, xresolution=210, yresolution=218, resolutionunit=2, datetime=2016:09:24 06:33:29, GPS-Data], baseline, precision 8, 5184x2912, frames 3
$ ./js_dump -f "IMG_6691.JPG"
0x00000002 0xd8 [SOI]
0x00007002 0xe1 [APP1]
0x00007fa0 0xe1 [APP1]
0x00008002 0xe2 [APP2]
0x00008088 0xdb [DQT]
0x0000809b 0xc0 [SOF0]
0x0000823f 0xc4 [DHT]
0x00008241 0xda [SOS]
0x003f24db 0x00 [!SCANDATA]
0x003f24dd 0xd9 [EOI]
panic: not on new segment marker: (00)
goroutine 1 [running]:
github.com/dsoprea/go-logging.PanicIf(0x5e6900, 0xc4200a2280)
/home/dustin/development/gopath/src/github.com/dsoprea/go-logging/log.go:476 +0x88
main.main()
/home/dustin/development/gopath/src/github.com/dsoprea/go-jpeg-image-structure/tools/js_dump/main.go:73 +0x177
The error is due to the file-pointer not sitting at the end of the file but yet not on a new marker.
User contributions licensed under CC BY-SA 3.0