Fixed metadata now saving to files
This commit is contained in:
parent
b948174936
commit
2d2b4c769c
1 changed files with 4 additions and 3 deletions
|
|
@ -35,9 +35,9 @@ def pull_usercomment_dict(filepath):
|
||||||
except InvalidImageDataError:
|
except InvalidImageDataError:
|
||||||
logging.warning("Invalid data at {}. Skipping.".format(filepath))
|
logging.warning("Invalid data at {}. Skipping.".format(filepath))
|
||||||
return None
|
return None
|
||||||
if "Exif" in exif_dict and 37510 in exif_dict["Exif"]:
|
if "Exif" in exif_dict and piexif.ExifIFD.UserComment in exif_dict["Exif"]:
|
||||||
try:
|
try:
|
||||||
return json.loads(exif_dict["Exif"][37510].decode())
|
return json.loads(exif_dict["Exif"][piexif.ExifIFD.UserComment].decode())
|
||||||
except json.decoder.JSONDecodeError:
|
except json.decoder.JSONDecodeError:
|
||||||
logging.error(
|
logging.error(
|
||||||
f"Capture {filepath} has old, corrupt, or missing OpenFlexure metadata. Unable to reload to server."
|
f"Capture {filepath} has old, corrupt, or missing OpenFlexure metadata. Unable to reload to server."
|
||||||
|
|
@ -266,7 +266,7 @@ class CaptureObject(object):
|
||||||
# Metadata
|
# Metadata
|
||||||
self._metadata.update(metadata)
|
self._metadata.update(metadata)
|
||||||
|
|
||||||
self.save_metadata
|
self.save_metadata()
|
||||||
|
|
||||||
def save_metadata(self) -> None:
|
def save_metadata(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
@ -289,6 +289,7 @@ class CaptureObject(object):
|
||||||
exif_bytes = piexif.dump(exif_dict)
|
exif_bytes = piexif.dump(exif_dict)
|
||||||
# Insert exif into file
|
# Insert exif into file
|
||||||
piexif.insert(exif_bytes, self.file)
|
piexif.insert(exif_bytes, self.file)
|
||||||
|
logging.info(f"Finished saving metadata to {self.file}")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def metadata(self) -> dict:
|
def metadata(self) -> dict:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue