From e1e2888d3ed0508460a5e834daf3390d392cda29 Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Mon, 2 Mar 2020 00:03:12 +0100 Subject: [PATCH] Beautified output in a tablish format. --- exif_rad.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/exif_rad.py b/exif_rad.py index 091417f..2e23365 100755 --- a/exif_rad.py +++ b/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!'))