Restructured parts of the tool in preparation for new image output mechanism.
This commit is contained in:
parent
249acb6d85
commit
ef6080d64c
27
exif_rad.py
27
exif_rad.py
@ -3,7 +3,8 @@
|
||||
|
||||
"""Iterates over a bunch of .jpg or .cr2 files and matches
|
||||
DateTimeOriginal from Exif tag to DateTime in a csv log
|
||||
of a GeigerMuellerCounter. """
|
||||
of a GeigerMuellerCounter and writes its value to the UserComment
|
||||
Exif tag in µS/h"""
|
||||
|
||||
from datetime import datetime
|
||||
import os
|
||||
@ -58,19 +59,23 @@ for photo in args.photos:
|
||||
if csvtime == pictime:
|
||||
rad = round(float(csvrawcpm) * args.sifactor, 2)
|
||||
|
||||
# convert str to exif compatible string
|
||||
# Set key, value for new UserComment
|
||||
key = 'Exif.Photo.UserComment'
|
||||
new_comment = 'Radiation ☢ ' + str(rad) + ' µS/h'
|
||||
# user_comment = piexif.helper.UserComment.dump(new_comment, encoding="unicode")
|
||||
# exif_dict["Exif"][piexif.ExifIFD.UserComment] = user_comment
|
||||
metadata[key] = pyexiv2.ExifTag(key, new_comment)
|
||||
|
||||
# compile and write tags
|
||||
# exif_bytes = piexif.dump(exif_dict)
|
||||
|
||||
# be os aware and use the correct directory delimiter
|
||||
outfile = os.path.join(args.outdir, photo_basename)
|
||||
# write target file
|
||||
# print output
|
||||
# print found radiation levels
|
||||
print('{:<30} {:<20} {:<22}'.format(photo_basename, str(pictime), new_comment))
|
||||
|
||||
# be os aware and use the correct directory delimiter for destfile
|
||||
outfile = os.path.join(args.outdir, photo_basename)
|
||||
|
||||
if args.outdir == ".":
|
||||
print('Going to overwrite source file')
|
||||
# metadata.write()
|
||||
else:
|
||||
print('Going to copy source file to destdir and modify it there')
|
||||
|
||||
break
|
||||
else:
|
||||
print('{:<30} {:<20} {:<22}'.format(photo_basename, str(pictime), 'NOT FOUND!'))
|
||||
|
Loading…
Reference in New Issue
Block a user