feat: Automatically add missing exif fields
All checks were successful
ci/woodpecker/pr/woodpecker_ci Pipeline was successful
ci/woodpecker/pull_request_closed/woodpecker_ci Pipeline was successful
ci/woodpecker/push/woodpecker_ci Pipeline was successful
ci/woodpecker/tag/woodpecker_ci Pipeline was successful

This commit is contained in:
Mr Finchum 2025-08-13 13:43:02 +02:00
parent 9dc14cdfcb
commit 7f11a29c63
Signed by: CodeByMrFinchum
GPG key ID: C06071E8082FFA0B
3 changed files with 39 additions and 2 deletions

View file

@ -1,5 +1,15 @@
# Changelog # Changelog
## 1.7.x
### 1.7.0: Feature - Automatically Add Missing EXIF Fields
- Between versions 1.5 and 1.6, two new EXIF fields were introduced: `developer` and `time`.
- If these fields were missing in the local EXIF file, the program would still load but crash when processing an image.
- Previously, this could be fixed manually by adding the missing fields, something I could easily do myself, but not ideal for other users.
- The program now automatically checks if the local EXIF file has these fields, and if not, it adds them with default values.
- This might make it easier in the future to adjust local files.
---
## 1.6.x ## 1.6.x
### 1.6.0: Feature - Add Information from Developing Process ### 1.6.0: Feature - Add Information from Developing Process

View file

@ -11,7 +11,7 @@ def main():
app_settings = u.load_settings() app_settings = u.load_settings()
app = QtWidgets.QApplication(sys.argv) app = QtWidgets.QApplication(sys.argv)
try: try: # Check weather the pkg for theme is installed
import qdarktheme import qdarktheme
app_settings["theme"]["theme_pkg"] = True app_settings["theme"]["theme_pkg"] = True
except ImportError: except ImportError:
@ -20,7 +20,8 @@ def main():
if app_settings["theme"]["use_custom_theme"] and app_settings["theme"]["theme_pkg"]: if app_settings["theme"]["use_custom_theme"] and app_settings["theme"]["theme_pkg"]:
qdarktheme.setup_theme(app_settings["theme"]["mode"].lower()) qdarktheme.setup_theme(app_settings["theme"]["mode"].lower())
u.save_settings(app_settings) u.save_settings(app_settings) # Save the settings after check to ensure that everything is present if enabled.
u.adjust_exif_after_update()
window = OptimaLab35() window = OptimaLab35()
window.show() window.show()

View file

@ -47,6 +47,23 @@ class Utilities:
if not self.write_yaml(self.settings_path, settings): if not self.write_yaml(self.settings_path, settings):
print("Error writing file") print("Error writing file")
def adjust_exif_after_update(self):
"""Adds new info the exif file after an update if needed"""
new_lst = ["developer", "time"] # for update from 1.5 to 1.6
current_lst = []
exif = self.read_yaml(self.exif_path)
for key in exif:
current_lst.append(key)
if all(item in current_lst for item in new_lst):
return
else:
print("Adding new exif data after update from 1.5")
exif["time"] = ["NA", "7:30", "10:00"]
exif["developer"] = ["NA", "Kodac HC-110 1:31", "Kodac HC-110 1:63"]
self.write_yaml(self.exif_path, exif)
def default_exif(self): def default_exif(self):
"""Makes a default exif file.""" """Makes a default exif file."""
print("Making default") print("Making default")
@ -89,6 +106,15 @@ class Utilities:
"user_comment": [ "user_comment": [
"Scanner: NORITSU-KOKI", "Scanner: NORITSU-KOKI",
"Scanner: NA" "Scanner: NA"
],
"developer": [
"Kodak HC-110 1:31",
"Kodak HC-110 1:63"
],
"time": [
"NA",
"7:00",
"10:00"
] ]
} }
self.write_yaml(self.exif_path, def_exif) self.write_yaml(self.exif_path, def_exif)