Skip to content

Instantly share code, notes, and snippets.

@ca057
Last active November 21, 2024 18:15
Show Gist options
  • Save ca057/b4dc3128234d03045ef8b881833e3da5 to your computer and use it in GitHub Desktop.
Save ca057/b4dc3128234d03045ef8b881833e3da5 to your computer and use it in GitHub Desktop.
Extracting EXIF data into JSON

command line tools for working with images to json

Extract all exif data as list into a json file:

exiftool -j -q dir > data.json

Sort the exif data by the original creation time:

jq 'sort_by(.DateTimeOriginal)' data.json

Extract exif data and sort by original creation time:

exiftool -j -q *.jpg | jq 'sort_by(.DateTimeOriginal)' > data.json
@Deankinyua
Copy link

is there a way i can just get the object and not in a list ?

@ca057
Copy link
Author

ca057 commented Nov 21, 2024

I’m not entirely sure what you want to achieve, but this should be a solution (let me know if this is not the case or you have another case in mind):

If you want to have the exif data of just a single file, call exiftool only on that file and extract the first (and therefore only) element of the array using jq:

exiftool -j -q your-image.jpg | jq '.[0]'
# alternatively write it to a file
exiftool -j -q your-image.jpg | jq '.[0]' > data.json

@Deankinyua
Copy link

Thanks let me see if this is what I'm looking for

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment