Extracting embedded images from Samsung phone (S8) "Selective Focus" shots

Started by ubacher, May 07, 2017, 02:07:32 AM

Previous topic - Next topic

jumpjack

Quote from: Phil Harvey on July 26, 2018, 12:58:51 PM
OK.  Use the exiftool -htmldump option to look in detail at the structure of a JPEG.

Note that the information you are looking for is likely all found in the (completely undocumented) Samsung trailer.

- Phil
amazing output!
thanks!

jumpjack

Anyway all information I need is just where to start from and end to when copying the two images streams into separate files.

Phil Harvey

Quote from: jumpjack on July 26, 2018, 01:07:23 PM
Anyway all information I need is just where to start from and end to when copying the two images streams into separate files.

Right.  Good question.  I'll let you know what I find out.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

Thanks for the samples.

ExifTool already parses this information if you look at the exiftool -v3 output for these files, but doesn't extract some new tags which contain the information you want.

It seems that the FlipPhoto JPEG is stored in SamsungTrailer_0x0a20.  I will add the ability to extract this in the next version of ExifTool... but what to name this tag?  "FlipPhotoImage"?

The interactive panorama is a 3GP video stored in SamsungTrailer_0x0201 -- I'll add the ability to extract this as well.  (Called "InteractivePanoramaVideo"?  Do you have a better suggestion?)

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

jumpjack

Quote from: Phil Harvey on July 27, 2018, 07:58:53 AM
Thanks for the samples.

ExifTool already parses this information if you look at the exiftool -v3 output for these files, but doesn't extract some new tags which contain the information you want.

It seems that the FlipPhoto JPEG is stored in SamsungTrailer_0x0a20.  I will add the ability to extract this in the next version of ExifTool...
Thanks for the analysis.
I am eager to see next version, but in the meantime, could you provide any tip about fields and offsets to look for by myself, to attempt starting to write the procedure which extracts the 2 streams?
I have yet to understand how to find the beginning of various segments in a JPEG file.
I can find the SOI (of course), then the APP1, but then I see multiple SOIs (FFD8)  and EOIs (FFD9) and I get confused.
Have they fixed length? The couple of bytes after the signature looks like not matching with actual length of the data segment...


Quote
but what to name this tag?  "FlipPhotoImage"?

The interactive panorama is a 3GP video stored in the SamsungTrailer_0x0201 tag -- I'll add the ability to extract this as well.  (Called "InteractivePanoramaVideo"?  Do you have a better suggestion?)


I think it's better to stick to Samsung naming: as they label these pictures "FlipPhoto_002" (why "always "2"?!?) and "Interactive_Panorama_000" (Why always "000"?) , I think it's better to name them "Samsung Flip-photo image" and "Samsung Interactive Panorama Image" (it's not properly a video, being stored inside a JPEG; it's more like an animated JPEG).

Once extracted, the video is no more interactive, it's just a video.

Phil Harvey

Ooops.  I was too fast.

I've gone ahead and released ExifTool 11.07 with the tag names that I had suggested.  You can download the new version from the ExifTool home page.

Look at the ExifTool source code for hints on how to decode this information.  The lengths are not fixed, so it is best to parse the Samsung trailer properly.  See Samsung.pm for my Perl code to do this.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

jumpjack

Quote from: jumpjack on July 27, 2018, 08:34:54 AM
I think it's better to stick to Samsung naming: as they label these pictures "FlipPhoto_002" (why "always "2"?!?) and "Interactive_Panorama_000" (Why always "000"?) , I think it's better to name them "Samsung Flip-photo image" and "Samsung Interactive Panorama Image" (it's not properly a video, being stored inside a JPEG; it's more like an animated JPEG).

Once extracted, the video is no more interactive, it's just a video.

It looks like iternal names are different from public names:
FliPhoto = Dual Camera
Interactive Panorama = Surround Shot
https://gadgetguideonline.com/s7/sasmung-galaxy-s7-how-to-guides/how-to-download-and-install-galaxy-s7-camera-modes/

Maybe it's better to use public names for better discoverability from search engines, and use internal names only in exif documentation.

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

jumpjack

Quote from: Phil Harvey on July 27, 2018, 08:42:00 AM
Ooops.  I was too fast.

I've gone ahead and released ExifTool 11.07
Where can I download windows executable from?

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).


jumpjack

This commandline:
>exiftool -a -b -Samsung:FlipPhotoImage  -w aaaa%c.jpg double.jpg

...results in a single image, maybe because of this output from -a -G1 -s (just one image):
FlipPhotoName                   : FlipPhoto_002
FlipPhotoImage                  : (Binary data 297999 bytes, use -b option to extract)

But the original file is opened by image viewers showing the first of two images, so  it's "almost ok" :-)

This commandline:
>exiftool -a -b -Samsung:InteractivePanoramaVideo -w test.3gp rotanting.jpg

...results in a working .3gp video, so it's ok.

----------

So, in this double shot, which one is the stream of the first image and which one is the second? (see attachment)

Phil Harvey

I'd say the main JPEG is the first image, starting at offset 0.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

jumpjack

But why are there three SOIs and three EOIs... but they are not nested?!? it is a nonsense.
How many images are here?
Where does first one start from and end to?
Where does second one start from and end to?

Extended version of previous image is attached, and it is associated to the image I sent you, 0006.jpg.
What's the second FFd9 for?
How can I determine where the first stream ends? I see an "FF FF" sequence after FF D8 FF E1, which should be data length, but actually is not.


Phil Harvey

I suggest that you spend some time looking at the ExifTool -htmldump and -v3 outputs.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).