Skip to content

Instantly share code, notes, and snippets.

@Russell-Tran
Russell-Tran / tif-exif.py
Last active April 17, 2024 06:32
Store custom data in .tif EXIF metadata using Python
from PIL import Image
# Use the UserComment field, since manufacturers et al. leave it empty
# https://www.awaresystems.be/imaging/tiff/tifftags/privateifd/exif/usercomment.html
EXIF_USERCOMMENT = 37510
def write_exif(src_path, dst_path, json_dict):
"""Write json (dictionary)
"""
write_exif_string(src_path, dst_path, json.dumps(json_dict))