Beautified output in a tablish format.

This commit is contained in:
Marcus Scholz 2020-03-02 00:03:12 +01:00
parent 6e4a955fe2
commit e1e2888d3e
1 changed files with 7 additions and 6 deletions

View File

@ -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!'))