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?

  • 1
    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

I am the author of Photopea.com - in-browser photo editor.

Photopea supports depth-maps. Open your JPG in Photopea, depth-map (and the original sharp image) will be added as two extra layers. You can save them separately as JPG, PNG, etc.

Just wanted to let you know, that you can do it without downloading or installing anything, or using a command line :)

UPDATE: There is a lens blur filter (Filter - Blur - Lens Blur), where you can produce a bokeh effect based on a depth map.

  • Does your software also automatically use the depth map to simulate bokeh? – xiota Aug 2 '19 at 8:42
  • Do you mean keeping one object sharp, and blurring everything what is closer or further than that object? There is no such feature, but I can implement it. But usually, cameras produce such image themselves. – Ivan Kuckir Aug 2 '19 at 8:54
  • What do you believe to be the purpose of the depth map? I don't use your software, so it doesn't matter to me what you decide to implement. Just wondered whether your software is capable of doing anything useful with the depth map. – xiota Aug 2 '19 at 9:10
  • 1
    It can only "extract" it at the moment (as a layer of pixels). You can save the depth map as PNG to be used in other software (what the person above asked for). – Ivan Kuckir Aug 2 '19 at 9:24
  • @xiota depth map can be serve a variety of purposes outside of the software us'ed to extrackt them. U can use depth map to impress all your friends on facebook with 2.5D photos facebook.com/help/1703757313215897/?helpref=hc_fnav – cmarangu Mar 24 '20 at 17:36

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

I have to make a ported application called ExifTool on Android. You can easily download it and try to extract the depth information or export the binary file from a photo.

Link download: Exif Tool on Android

How to use:

  • Open app.
  • Choose a photo that have Depth Map data.
  • Tap to XMP tab, then see the DepthMap thumbnail, ImageData thumbnail.
  • Tap to DepthMap or ImageData tag to pick a storage that you want to export.
  • Pick a folder to export.
  • Then, finish. enter image description here
  • Are you associated with the Android program you are linking to? – scottbb Mar 11 '20 at 5:53
  • 1
    And if you are associated that's fine, but please mention it in the answer. Also, the answer at the moment doesn't describe how one would use exiftool on android to extract the depth map. Could you please add that as well? Thanks! – Saaru Lindestøkke Mar 11 '20 at 19:26
  • Yes, I can, updated comment. – Võ Anh Kiệt Mar 12 '20 at 10:36
  • Thanks for the update with instructions, but you still haven't disclosed whether you're associated with the product or not. Promoting a product you're associated with is quite OK, but acknowledgement of that is expected. If you're not associated, you can just include some text like "I'm a happy user of ..." to indicate that. – FreeMan Mar 12 '20 at 14:09
  • I don't think this is needed on this post. But, It's OK to say that is my product, I have to update my comment in this post. Thank you for pointing me. – Võ Anh Kiệt Mar 12 '20 at 18:19

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.