Renamed photo class attribute.
Figured how to acces class objects. Moved write_exif to own Exif class to compile GPS coords and write them all.
This commit is contained in:
17
functions.py
17
functions.py
@@ -9,7 +9,7 @@ import shutil
|
||||
import pyexiv2
|
||||
|
||||
class Radiation:
|
||||
''' Handles CSV processing.'''
|
||||
''' Handles CSV processing. '''
|
||||
def __init__(self, timestamp, radiation, local_timezone, si_factor):
|
||||
self.timestamp = self._time_conversion(timestamp, local_timezone)
|
||||
self.radiation = self._radiation_conversion(radiation, si_factor)
|
||||
@@ -29,13 +29,13 @@ class Radiation:
|
||||
return radiation
|
||||
|
||||
class Photo:
|
||||
''' Reads and writes Exif metadata'''
|
||||
''' Reads and writes Exif metadata. '''
|
||||
def __init__(self, photo, local_timezone, dest_dir, dry_run):
|
||||
self.get_date = self._get_creation_date(photo, local_timezone)
|
||||
self.copy_photo = self._copy_photo(photo, dest_dir, dry_run)
|
||||
self.get_target_photo = self._copy_photo(photo, dest_dir, dry_run)
|
||||
|
||||
def __repr__(self):
|
||||
return 'Photo: %s Creation Date: %s' % (str(self.copy_photo), str(self.get_date))
|
||||
return 'Photo: %s Creation Date: %s' % (str(self.get_target_photo), str(self.get_date))
|
||||
|
||||
def _copy_photo(self, photo, dest_dir, dry_run):
|
||||
# Determine where to work on photo and copy it there if needed.
|
||||
@@ -48,7 +48,7 @@ class Photo:
|
||||
# if not in dry_run mode or if dest_dir is different from src_dir.
|
||||
if dry_run is True:
|
||||
return photo
|
||||
elif dest_dir != '.':
|
||||
if dest_dir != '.':
|
||||
shutil.copy(photo, dest_photo)
|
||||
return dest_photo
|
||||
|
||||
@@ -56,6 +56,7 @@ class Photo:
|
||||
# Load Exif data from photo
|
||||
metadata = pyexiv2.ImageMetadata(photo)
|
||||
metadata.read()
|
||||
print(metadata)
|
||||
date = metadata['Exif.Photo.DateTimeOriginal']
|
||||
# date.value creates datetime object in pic_naive_time
|
||||
pic_naive_time = date.value
|
||||
@@ -63,12 +64,14 @@ class Photo:
|
||||
pic_aware_time = pic_naive_time.astimezone(local_timezone)
|
||||
return pic_aware_time
|
||||
|
||||
def write_exif(self, photo, radiation, latitude, longitude, dry_run):
|
||||
class Exif:
|
||||
''' Compiles and writes Exif-Tags from given values. '''
|
||||
def write_exif(photo, radiation, latitude, longitude, dry_run):
|
||||
|
||||
''' UNTESTED ! '''
|
||||
|
||||
metadata = pyexiv2.ImageMetadata(photo)
|
||||
|
||||
metadata.read()
|
||||
# Set new UserComment
|
||||
new_comment = 'Radiation ☢ ' + str(radiation) + ' µS/h'
|
||||
# Exif tags to write
|
||||
|
Reference in New Issue
Block a user