Skip to content

Commit

Permalink
add iptc keyword tagging parsing
Browse files Browse the repository at this point in the history
closes #16
  • Loading branch information
bencevans committed Jul 19, 2022
1 parent 86fa5bc commit 27aef2f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions camtrapml/image/exif.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,23 @@ def extract_multiple_exif_fast(paths: List[Union[Path, str]], batch_size=100) ->

# Unbatch
return [item for sublist in exif_data for item in sublist]

def parse_iptc(keywords) -> dict:
"""
Parses IPTC Tags
"""

if isinstance(keywords, str):
keywords = [keywords]

def parse(keyword):
split = keyword.split(':')
if len(split) == 1:
return split[0], True

key = split[0].strip()
val = split[1].strip()

return key, val

return [parse(keyword) for keyword in keywords]

0 comments on commit 27aef2f

Please sign in to comment.