Extract Drone Photos Exif Data to JSON using ExifTool and Python

Tommy
1 min readMay 7, 2022

--

I had lots of drone photo, and I want to visualize the geolocation record (latitude, longitude, altitude) and orientation in map. These data can be found in photos exif, but its binary format is indeed annoying, it’s hard to decode.

I tried various Python and JavaScript libraries to decode, but quite a lot cannot completely decode to a usable format. My requirement is “simple”, just want to save all attributes in json format.

ExifTool Website

Fortunately I found a great library, ExifTool. It is a platform-independent command line tools (no GUI in MacOS), one line command in terminal can extract exif to json.

exiftool /image/file.jpg -j

Json data will be printed in terminal.

Since I want to save the json in a more organized way, save json in designated filename and location. Combining exiftool with Python subprocess seems working.

import subprocess
import glob
images_paths = glob.glob(f"/your/image/directory/**/*.JPG")for image_path in images_paths:
with open(f"designate/filename.json", "w") as f:
subprocess.call(["exiftool", image_path, "-j", ], stdout=f)

subprocess.call will run “exiftool {imagepath} -j”, the json output will be passed to stdout(f), which will be saved in designate/filename.json.

Using subprocess to join non-Python library into python code gives extra power to python. :P

--

--