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

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

Previous topic - Next topic

ubacher

The Samsung smartphone (S8) produces two extra embedded images in the recorded jpg file.
[Samsung]       Embedded Image Name             : FocusShot_1
[Samsung]       Embedded Image                  : (Binary data 6202056 bytes, use -b option to extract)
[Samsung]       Embedded Image Name             : FocusShot_2
[Samsung]       Embedded Image                  : (Binary data 5782454 bytes, use -b option to extract)
[Samsung]       Time Stamp                      : 2017:05:05 19:14:30+02:00

I assume these are regular jpg files but with a different focus point.
How can I extract these? Command line syntax please!
( I have exiftoolgui, I can handle command lines if need be, I use Imatch - from within Imatch I will eventually perform the extract.)

Stephen Marsh

Can you try the following command to see how the duplicates are listed?

exiftool -a -G1 -s 'mac os/path/to/file or directory/here.jpg'

exiftool -a -G1 -s "ms windows\path\to\file or directory\here.jpg"


EDIT:

Ah, I think that was the duplicate output! So, are your tags named?:

-Samsung:FocusShot_1

and

-Samsung:FocusShot_2

Stephen Marsh

CLI examples here (#11 and #12):

https://exiftool.org/examples.html


For my Olympus camera, a similar command line example from the raw file would be:

exiftool -b -Olympus:PreviewImage -w %d%f.jpg FILE-or-DIR (Raw)

While for my Canon, possible tags would be:

-IFD0:PreviewImage (Raw)

-IFD1:ThumbnailImage (JPEG)


However as you already have a JPG, you don't want to use exactly the same name with only the %d%f arguments... so:

exiftool -b -Samsung:FocusShot_1 -w %d%f_FocusShot_1.jpg FILE-or-DIR

exiftool -b -Samsung:FocusShot_2 -w %d%f_FocusShot_2.jpg FILE-or-DIR

Phil Harvey

You can try this command:

exiftool -embeddedImage -b -W %d%f%c.%s DIR

- 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 ($).

Stephen Marsh

%d%f%c.%s = Cool!

http://www.exiftool.org/exiftool_pod.html

%d = directory
%f = filename
%c = copy number
.
%s = suggested extension

Thanks Phil!

ubacher

exiftool -embeddedImage -b -W %d%f%c.%s DIR from Phil
works but extracts only one of the two images.
exiftool -b -Samsung:FocusShot_1 -w %d%f_FocusShot_1.jpg FILE-or-DIR from Stephen
does not work: says 0 output files created.
I am doing this on Windows 10 command line.

When I list with exiftool -a -G1 -s I get the output shown in my initial post.

Looks like the problem is that the tag ID and the tag content are on seperate lines.
Phil: Is there a way around this????




Phil Harvey

Right, I forgot to add -a to allow duplicate tags:

exiftool -embeddedImage -a -b -W %d%f%c.%s DIR

(the "FocusShot_1" name is just what Samsung calls the embedded image.  It has nothing to do with the ExifTool tag names)

- 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 ($).

ubacher

That's it.
Thank you for your guidance thru the exiftool option jungle.
(I will buy you a beer the next time I am in Kingston.)

jumpjack

Thanks for very useful information, I was getting nut figuring out how to analyze a JPEG file to extract multi-images from samsung images.
Fortunately this led to me to discover the amazinh hex editor FlexHex (free for educational and non-profit organizations)... although I was not able to create the right .FSD file to indentify all fields.

All I was able to do is this, for those interested (just copy following code inside xxxx.fsd text file and load it into FlexHex from menu Edit-->Structure-->Load

struct _JPEGHeader
{
  BYTE SOI[2];          /* 00h  Start of Image Marker     */
  BYTE APP0[2];         /* 02h  Application Use Marker    */
  WORD Length;       /* 04h  Length of APP0 Field      */
  char Identifier[5];   /* 06h  "JFIF" (zero terminated) Id String */
  hex WORD Version;      /* 07h  JFIF Format Revision      */
  BYTE Units;           /* 09h  Units used for Resolution */
  unsigned WORD Xdensity;     /* 0Ah  Horizontal Resolution     */
  unsigned WORD Ydensity;     /* 0Ch  Vertical Resolution       */
  unsigned BYTE XThumbnail;      /* 0Eh  Horizontal Pixel Count    */
  unsigned BYTE YThumbnail;      /* 0Fh  Vertical Pixel Count      */
}



That said... above command line works fine in extracting multifocus images (or "Focus Shots" as Samsung calls them), but fails in extracting "Double Shots" and "Interactive Panoramas" (images containing dozens of shots from different angles).

My "exiftool -a -G1 -s" outputs for a Double Shot and an Interactive Panorama:

[ExifTool]      ExifToolVersion                 : 11.06
[System]        FileName                        : 0001-double.jpg
[System]        Directory                       : .
[System]        FileSize                        : 2.9 MB
[System]        FileModifyDate                  : 2018:07:22 16:35:38+02:00
[System]        FileAccessDate                  : 2018:07:25 20:47:50+02:00
[System]        FileCreateDate                  : 2018:07:25 20:47:50+02:00
[System]        FilePermissions                 : rw-rw-rw-
[File]          FileType                        : JPEG
[File]          FileTypeExtension               : jpg
[File]          MIMEType                        : image/jpeg
[File]          ExifByteOrder                   : Little-endian (Intel, II)
[File]          ImageWidth                      : 3024
[File]          ImageHeight                     : 3024
[File]          EncodingProcess                 : Baseline DCT, Huffman coding
[File]          BitsPerSample                   : 8
[File]          ColorComponents                 : 3
[File]          YCbCrSubSampling                : YCbCr4:2:2 (2 1)
[IFD0]          Orientation                     : Rotate 90 CW
[IFD0]          YCbCrPositioning                : Centered
[IFD0]          XResolution                     : 72
[IFD0]          YResolution                     : 72
[IFD0]          ResolutionUnit                  : inches
[IFD0]          Make                            : samsung
[IFD0]          Model                           : SM-G930F
[IFD0]          Software                        : G930FXXU2ERE8
[IFD0]          ModifyDate                      : 2018:07:22 16:35:38
[ExifIFD]       ExposureTime                    : 1/25
[ExifIFD]       FNumber                         : 1.7
[ExifIFD]       ExposureProgram                 : Program AE
[ExifIFD]       ISO                             : 160
[ExifIFD]       ExifVersion                     : 0220
[ExifIFD]       DateTimeOriginal                : 2018:07:22 16:35:38
[ExifIFD]       CreateDate                      : 2018:07:22 16:35:38
[ExifIFD]       ShutterSpeedValue               : 1/25
[ExifIFD]       ApertureValue                   : 1.7
[ExifIFD]       BrightnessValue                 : 0.64
[ExifIFD]       ExposureCompensation            : 0
[ExifIFD]       MaxApertureValue                : 1.7
[ExifIFD]       MeteringMode                    : Center-weighted average
[ExifIFD]       Flash                           : No Flash
[ExifIFD]       FlashpixVersion                 : 0100
[ExifIFD]       ComponentsConfiguration         : Y, Cb, Cr, -
[ExifIFD]       FocalLength                     : 4.2 mm
[ExifIFD]       SubSecTime                      : 0868
[ExifIFD]       SubSecTimeOriginal              : 0868
[ExifIFD]       SubSecTimeDigitized             : 0868
[ExifIFD]       UserComment                     :
[ExifIFD]       ColorSpace                      : sRGB
[ExifIFD]       ExifImageWidth                  : 3024
[ExifIFD]       ExifImageHeight                 : 3024
[ExifIFD]       ExposureMode                    : Auto
[ExifIFD]       WhiteBalance                    : Auto
[ExifIFD]       FocalLengthIn35mmFormat         : 26 mm
[ExifIFD]       SceneCaptureType                : Standard
[ExifIFD]       ImageUniqueID                   : C12LLJB18SM C12LLLC01GM.
[InteropIFD]    InteropIndex                    : R98 - DCF basic file (sRGB)
[InteropIFD]    InteropVersion                  : 0100
[IFD1]          ImageWidth                      : 376
[IFD1]          ImageHeight                     : 376
[IFD1]          Compression                     : JPEG (old-style)
[IFD1]          Orientation                     : Rotate 90 CW
[IFD1]          ThumbnailOffset                 : 844
[IFD1]          ThumbnailLength                 : 15856
[IFD1]          ThumbnailImage                  : (Binary data 15856 bytes, use -b option to extract)
[Samsung]       TimeStamp                       : 2018:07:22 16:35:38+02:00
[Composite]     Aperture                        : 1.7
[Composite]     ImageSize                       : 3024x3024
[Composite]     Megapixels                      : 9.1
[Composite]     ScaleFactor35efl                : 6.2
[Composite]     ShutterSpeed                    : 1/25
[Composite]     SubSecCreateDate                : 2018:07:22 16:35:38.0868
[Composite]     SubSecDateTimeOriginal          : 2018:07:22 16:35:38.0868
[Composite]     SubSecModifyDate                : 2018:07:22 16:35:38.0868
[Composite]     CircleOfConfusion               : 0.005 mm
[Composite]     FOV                             : 69.4 deg
[Composite]     FocalLength35efl                : 4.2 mm (35 mm equivalent: 26.0 mm)
[Composite]     HyperfocalDistance              : 2.14 m
[Composite]     LightValue                      : 5.5






[ExifTool]      ExifToolVersion                 : 11.06
[System]        FileName                        : 0004rotante.jpg
[System]        Directory                       : .
[System]        FileSize                        : 2.7 MB
[System]        FileModifyDate                  : 2018:04:26 09:17:06+02:00
[System]        FileAccessDate                  : 2018:07:25 20:38:07+02:00
[System]        FileCreateDate                  : 2018:07:25 20:38:07+02:00
[System]        FilePermissions                 : rw-rw-rw-
[File]          FileType                        : JPEG
[File]          FileTypeExtension               : jpg
[File]          MIMEType                        : image/jpeg
[File]          ExifByteOrder                   : Little-endian (Intel, II)
[File]          ImageWidth                      : 1138
[File]          ImageHeight                     : 640
[File]          EncodingProcess                 : Baseline DCT, Huffman coding
[File]          BitsPerSample                   : 8
[File]          ColorComponents                 : 3
[File]          YCbCrSubSampling                : YCbCr4:2:0 (2 2)
[IFD0]          ImageWidth                      : 1138
[IFD0]          ImageHeight                     : 640
[IFD0]          Make                            : samsung
[IFD0]          Model                           : SM-G930F
[IFD0]          Orientation                     : Rotate 90 CW
[IFD0]          XResolution                     : 72
[IFD0]          YResolution                     : 72
[IFD0]          ResolutionUnit                  : inches
[IFD0]          Software                        : G930FXXU1DQJ8
[IFD0]          ModifyDate                      : 2018:04:26 09:17:06
[IFD0]          YCbCrPositioning                : Centered
[ExifIFD]       FNumber                         : 1.7
[ExifIFD]       ExposureProgram                 : Program AE
[ExifIFD]       ExifVersion                     : 0220
[ExifIFD]       DateTimeOriginal                : 2018:04:26 09:17:06
[ExifIFD]       CreateDate                      : 2018:04:26 09:17:06
[ExifIFD]       MaxApertureValue                : 1.7
[ExifIFD]       MeteringMode                    : Center-weighted average
[ExifIFD]       Flash                           : Off, Did not fire
[ExifIFD]       FocalLength                     : 4.2 mm
[ExifIFD]       ColorSpace                      : sRGB
[ExifIFD]       ExifImageWidth                  : 1138
[ExifIFD]       ExifImageHeight                 : 640
[ExifIFD]       ExposureMode                    : Auto
[ExifIFD]       WhiteBalance                    : Auto
[ExifIFD]       FocalLengthIn35mmFormat         : 26 mm
[ExifIFD]       SceneCaptureType                : Portrait
[ExifIFD]       ImageUniqueID                   : C
[IFD1]          ImageWidth                      : 496
[IFD1]          ImageHeight                     : 280
[IFD1]          Orientation                     : Rotate 90 CW
[JFIF]          JFIFVersion                     : 1.01
[JFIF]          ResolutionUnit                  : cm
[JFIF]          XResolution                     : 59
[JFIF]          YResolution                     : 59
[Samsung]       TimeStamp                       : 2018:04:26 09:17:06+02:00
[Composite]     Aperture                        : 1.7
[Composite]     ImageSize                       : 1138x640
[Composite]     Megapixels                      : 0.728
[Composite]     ScaleFactor35efl                : 6.2
[Composite]     CircleOfConfusion               : 0.005 mm
[Composite]     FOV                             : 69.4 deg
[Composite]     FocalLength35efl                : 4.2 mm (35 mm equivalent: 26.0 mm)
[Composite]     HyperfocalDistance              : 2.14 m



No [Samsung] tags appear in the output, but I can see them in the hex editor:
FlipPhoto_002
Interactive_Panorama_000


I tried attaching the two images 3MB each, with no success, although form says limit is 10MB each.

Phil Harvey

You can send the files to me directly.   My email is philharvey66 at gmail.com

- 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

about the JPEG structure, isn't there any official documenti about it? It looks like it is a secret... while GIF format, which is instead proprietary and pay-per-use, is widely documented!

Phil Harvey

I got the files, thanks.  I'll post back after I've had a chance to analyze them.

The JPEG/JFIF format specification is widely available.

- 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

I eventually found (after 2 days) a suitable document, by adding EXIF, SPIFF and JFIF to the search string:
http://dev.exiv2.org/projects/exiv2/wiki/The_Metadata_in_JPEG_files


I am trying to write my own "Samsung Dual Shot Extractor" so I need to understand very well this format mess!  ;)

Phil Harvey

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
...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 ($).