Some mobile phones support changing the depth of field using depth information calculated from dual cameras. If the depth information is stored in the jpg file, how can it be extracted?

  • Could you provide a source for the claim that this information is stored in the JPEG? – Philip Kendall Jan 15 '17 at 7:18
  • If you can tell me what the EXIF information is for that, I can probably make the software if it can't be done with EXIFTOOL. – MikeD Jan 15 '17 at 9:16
  • @PhilipKendall If I take a picture without using dual cameras, the size of the jpg file may be about 2Mbytes. If I use the dual cameras function to take the same scene, additional 2Mbytes is needed for the jpg file. I guess that depth information is saved in the jpg file. After you have taken the image, you can reload the jpg file and modify DOF in camera app on an Android phone. – Jogging Song Jan 15 '17 at 13:24
  • @MikeD I don't know which filed is used for depth information. JPEG file standard allows users to add private data. I try JPEGsnoop and not succeed. – Jogging Song Jan 15 '17 at 13:29
  • 1
    I've seen some Google phones that store depth information as Base 64 encoded data in XMP segments. Seems like a weird way to store it, but I'm sure they have a reason. Do you have a sample image? Could you open an issue on my project's issue tracker and attach it? github.com/drewnoakes/metadata-extractor – Drew Noakes Jan 15 '17 at 23:37

Portrait Mode images saved by Google Camera contain the original image and depth map in the metadata. They can be extracted with exiftool:

exiftool -b -ImageData image.jpg > image.gimage.jpg
exiftool -b -Data image.jpg > image.gdepth.jpg 

Google Cardboard panoramas contain audio and 3d image data.

exiftool -trailer:all= image.jpg -o image.1.jpg
exiftool -b -ImageData image.jpg > image.2.jpg
exiftool -b -AudioData image.jpg > image.audio.mp4

For dual camera Android phones, the exact command required depends on which tags a specific phone or app uses to store extra images. To find the name of the tags, use:

exiftool image.jpg | grep -i binary

For example, the original images stored by the Samsung S9+ can be extracted with the following commands:

exiftool -trailer:all= image.jpg -o image.1.jpg
exiftool -b -EmbeddedImage image.jpg > image.2.jpg

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.