Beautified output in a tablish format.
This commit is contained in:
parent
6e4a955fe2
commit
e1e2888d3e
13
exif_rad.py
13
exif_rad.py
@ -50,15 +50,12 @@ with open(args.csv, "r") as f:
|
||||
|
||||
picrawtime = exif_dict['Exif'][piexif.ExifIFD.DateTimeOriginal].decode('ASCII')
|
||||
picisotime = datetime.strptime(picrawtime, "%Y:%m:%d %H:%M:%S")
|
||||
print('\nProcessing file:', photo_basename)
|
||||
print('Timestamp of image:', picisotime)
|
||||
print('Processing file:', photo_basename, end='\r')
|
||||
for _, csvrawtime, csvrawcpm, _ in csvreader:
|
||||
csvisotime = datetime.fromisoformat(csvrawtime)
|
||||
|
||||
if csvisotime == picisotime:
|
||||
rad = round(float(csvrawcpm) * args.sifactor, 2)
|
||||
print('Found matching timestamp!')
|
||||
print('Radiation at time of photo:', rad, 'µS/h')
|
||||
|
||||
# convert str to exif compatible string
|
||||
new_comment = 'Radiation ☢ ' + str(rad) + ' µS/h'
|
||||
@ -66,10 +63,14 @@ with open(args.csv, "r") as f:
|
||||
exif_dict["Exif"][piexif.ExifIFD.UserComment] = user_comment
|
||||
|
||||
# compile and write tags
|
||||
print('Going to write comment:', new_comment)
|
||||
exif_bytes = piexif.dump(exif_dict)
|
||||
|
||||
# be os aware and use the correct directory delimiter
|
||||
outfile = os.path.join(args.outdir, photo_basename)
|
||||
im.save(outfile, exif=exif_bytes)
|
||||
|
||||
# print output
|
||||
print('{:<30} {:<20} {:<22}'.format(photo_basename, str(picisotime), new_comment))
|
||||
break
|
||||
else:
|
||||
print('Found NO matching timestamp, Not going to modify photo.')
|
||||
print('{:<30} {:<20} {:<22}'.format(photo_basename, str(picisotime), 'NOT FOUND!'))
|
||||
|
Loading…
Reference in New Issue
Block a user