ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: drcq on December 29, 2024, 01:20:42 PM

Title: PreviewImage tag in Sony's MakerNote - tag 0x2001
Post by: drcq on December 29, 2024, 01:20:42 PM
I investigated the PreviewImage tag for a lot of Sony cameras (DSC-RX100M7, DSLR-, ILCE-, ILCA-,NEX-, SLT-) and found out, that all models follow the same schema. The implementation is different for cameras with and without MP-images only. In my opinion the ExifTool documentation could be simplified.

Take a look at DSLR-A200 (JPG-format):
This is the crucial point! Just replace the 0x00 with 0xff and we have the SOI (start-of-image) marker. The length value fits exactly with the EOI marker. Starting at PreviewImage address + 0x20 bytes for the info block, we have our JPG Preview image.
The content of this image is shown below.
JPEG DQT (130 bytes):
JPEG DHT (416 bytes):
JPEG SOF0 (15 bytes):
  ImageWidth = 1616
  ImageHeight = 1080
  EncodingProcess = 0
  BitsPerSample = 8
  ColorComponents = 3
  YCbCrSubSampling = 2 1
JPEG SOS


To understand, why Sony is writing 0x00d8 instead of 0xffd8, we must look at an image with MP-Image inside.

Take a look at DSLR-A380 image (JPG-format):

Now we must look at the MP image layout shown below.

MPImage-layout.png

The image info block is located between the MakerNote IFD and the DQT segment of the MP image. The JPG reader for the MP Image will skip the preview image block while processing the APP1 segment (0x750007 + 0x00000c + 2 = 0x750095). So we can process and save the PreviewImage content using the MP tags only (address and length). This APP1 segment contains 3 IFD's (see next picture below). Using 0x00d8 instead of 0xffd8 is avoiding errors with JPG-reader searching the binary data for JPG markers (always starting with 0xff!)

But Sony also supports saving of the PreviewImage content as a plain JPG. Just replace the 0x00d8 with 0xffd8 behind the image info block and store the next 0x00128a02 bytes.

MPImage-tags.png

One point is still unclear to me! The MakerNote IFD of the MP Image contains also the PreviewImage tag (0x2001) but specifying the wrong address!
Title: Re: PreviewImage tag in Sony's MakerNote - tag 0x2001
Post by: Phil Harvey on December 29, 2024, 06:13:04 PM
I'm not clear on how you think ExifTool could be improved.

- Phil
Title: Re: PreviewImage tag in Sony's MakerNote - tag 0x2001
Post by: drcq on December 30, 2024, 11:22:22 AM
Hi Phil,

just update the notes, that the preview image starts directly behind the 32 byte info block and 0x00d8 value should be interpreted as 0xffd8 (SOI marker). The current info is a little bit confusing.

        # DSLR-A230/A290/A330/A380/A390:
        # - PreviewImage start-offset is at 110 bytes inside MPImage2
        # DSLR-A450/A500/A550/A560/A580, SLT-A33/A35/A55V, NEX-3/5/5C/C3/VG10/VG10E:
        # - PreviewImage start-offset is at 106 bytes inside MPImage2
        # - different first bytes after 32-byte header
        # SLT-A37/A57/A58/A65V/A77V/A99V, ILCA-77M2, NEX-3N/5N/5R/5T/6/7/F3, ILCE-3000/3500/5000/6000/7/7R/7S:
        # - PreviewImage start-offset is at 130 bytes inside MPImage2

The preview image start-offset is always directly behind the info block and isn't dependent on the camera type.

Regards,
Christoph
Title: Re: PreviewImage tag in Sony's MakerNote - tag 0x2001
Post by: Phil Harvey on December 30, 2024, 02:52:36 PM
Hi Christoph,

Thanks for explaining, but I think the comments may be correct, but seeminly misleading.

I think the PreviewImage data exists in the MPImage2 trailer at the specified offset within this trailer.  The pointer for tag 0x2001 points into the MPImage2 trailer, at an offset of 32 bytes before the start of the image.

And you are correct, the first byte of the image may not be 0xff as it should be, but this is mentioned in the comments, at least for some models.

BTW, these comments are by Jos Roost, who has done much of the Sony decoding.

- Phil
Title: Re: PreviewImage tag in Sony's MakerNote - tag 0x2001
Post by: drcq on December 31, 2024, 09:33:48 AM
Hi Phil,

First of all - Happy New Year 2025!

Thanks for your fast response. I don't like to appear stubborn, but the first DLSR cameras (like A350 and A200) released in the beginning of 2008 use already PreviewImage tag without the MP-image support. The PreviewImage tag points to the 32-bit block (with image length and dimension values) and the image starts directly behind the info block with 0x00d8.

With the DSLR-A550 and A380 cameras (released in 2009) we got MP support. In my opinion, Sony decided to introduce APP2-MPF support while still keeping the PreviewImage solution of the earlier cameras. If you look at my pictures above, you can see that the PreviewImage and the MP2-Image have the same binary content. The difference is, that the MP-Image starts with an APP1-Exif segment. The SonyIFD content located in this APP1-Exif segment ends at 0x00750072 and the info block starts directly behind at 0x00750073. The DQT segment at 0x00750095 is used by both "images": MP image and Preview image.

So you are right, the PreviewImage points to the APP1-Exif segment trailer of the MP-Image. But I'm impressed about the way, how Sony implemented this "additional entry" into the MP-Image.

All the best for 2025!
Christoph