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')
|
picrawtime = exif_dict['Exif'][piexif.ExifIFD.DateTimeOriginal].decode('ASCII')
|
||||||
picisotime = datetime.strptime(picrawtime, "%Y:%m:%d %H:%M:%S")
|
picisotime = datetime.strptime(picrawtime, "%Y:%m:%d %H:%M:%S")
|
||||||
print('\nProcessing file:', photo_basename)
|
print('Processing file:', photo_basename, end='\r')
|
||||||
print('Timestamp of image:', picisotime)
|
|
||||||
for _, csvrawtime, csvrawcpm, _ in csvreader:
|
for _, csvrawtime, csvrawcpm, _ in csvreader:
|
||||||
csvisotime = datetime.fromisoformat(csvrawtime)
|
csvisotime = datetime.fromisoformat(csvrawtime)
|
||||||
|
|
||||||
if csvisotime == picisotime:
|
if csvisotime == picisotime:
|
||||||
rad = round(float(csvrawcpm) * args.sifactor, 2)
|
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
|
# convert str to exif compatible string
|
||||||
new_comment = 'Radiation ☢ ' + str(rad) + ' µS/h'
|
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
|
exif_dict["Exif"][piexif.ExifIFD.UserComment] = user_comment
|
||||||
|
|
||||||
# compile and write tags
|
# compile and write tags
|
||||||
print('Going to write comment:', new_comment)
|
|
||||||
exif_bytes = piexif.dump(exif_dict)
|
exif_bytes = piexif.dump(exif_dict)
|
||||||
|
|
||||||
|
# be os aware and use the correct directory delimiter
|
||||||
outfile = os.path.join(args.outdir, photo_basename)
|
outfile = os.path.join(args.outdir, photo_basename)
|
||||||
im.save(outfile, exif=exif_bytes)
|
im.save(outfile, exif=exif_bytes)
|
||||||
|
|
||||||
|
# print output
|
||||||
|
print('{:<30} {:<20} {:<22}'.format(photo_basename, str(picisotime), new_comment))
|
||||||
break
|
break
|
||||||
else:
|
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