-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
39 lines (36 loc) · 1.37 KB
/
Copy pathconfig.py
File metadata and controls
39 lines (36 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import json
import os
import sys
# Configuration file path
if hasattr(sys, '_MEIPASS'):
CONFIG_FILE = os.path.join(os.path.dirname(sys.executable), "config.json")
else:
CONFIG_FILE = "config.json"
# Function to save configuration
def save_config(b_mode, output_folder, thumb_size, preserve_exif, remove_gps):
config_data = {
"b_mode": b_mode,
"output_folder": output_folder,
"thumb_size": thumb_size,
"preserve_exif": preserve_exif,
"remove_gps": remove_gps,
}
with open(CONFIG_FILE, "w") as f:
json.dump(config_data, f, indent=4)
# Function to load configuration
def load_config():
if os.path.exists(CONFIG_FILE):
try:
with open(CONFIG_FILE, "r") as f:
data = json.load(f)
return {
"b_mode": data.get("b_mode", "light"),
"output_folder": data.get("output_folder", ""),
"thumb_size": data.get("thumb_size", 100),
"preserve_exif": data.get("preserve_exif", False),
"remove_gps": data.get("remove_gps", False),
}
except (json.JSONDecodeError, KeyError):
pass
# If file doesn't exist or is corrupted, return default settings
return {"b_mode": "light", "output_folder": "", "thumb_size": 100, "preserve_exif": False, "remove_gps": False}