|
1
|
#!/usr/bin/env python
|
|
2
|
# -*- coding: utf-8 -*-
|
|
3
|
|
|
4
|
import json
|
|
5
|
|
|
6
|
class ConfigReader:
|
|
7
|
"""
|
|
8
|
ConfigReader loads configuration settings from a JSON file.
|
|
9
|
It now uses a single base path for input images.
|
|
10
|
"""
|
|
11
|
|
|
12
|
def __init__(self, json_path: str):
|
|
13
|
"""
|
|
14
|
Initialize the ConfigReader with the path to the configuration file.
|
|
15
|
:param json_path: Path to the JSON configuration file
|
|
16
|
"""
|
|
17
|
self.json_path = json_path
|
|
18
|
self.config = None
|
|
19
|
self.load_config()
|
|
20
|
|
|
21
|
def load_config(self):
|
|
22
|
"""Load configuration data from the JSON file."""
|
|
23
|
try:
|
|
24
|
with open(self.json_path, 'r', encoding='utf-8') as f:
|
|
25
|
self.config = json.load(f)
|
|
26
|
except FileNotFoundError:
|
|
27
|
raise FileNotFoundError(f"Configuration file not found: {self.json_path}")
|
|
28
|
except json.JSONDecodeError as e:
|
|
29
|
raise ValueError(f"Error decoding JSON: {e}")
|
|
30
|
|
|
31
|
def get_blend_width(self) -> int:
|
|
32
|
"""Return the blending width."""
|
|
33
|
return self.config.get("blend_width", 200)
|
|
34
|
|
|
35
|
def get_gamma_value(self) -> float:
|
|
36
|
"""Return the gamma correction value."""
|
|
37
|
return self.config.get("gamma_value", 1.0)
|
|
38
|
|
|
39
|
def get_blend_method(self) -> str:
|
|
40
|
"""Return the blending method (e.g., 'cosine', 'linear')."""
|
|
41
|
return self.config.get("blend_method", "linear")
|
|
42
|
|
|
43
|
def get_image_path(self) -> str:
|
|
44
|
"""Return the base directory of the input images."""
|
|
45
|
return self.config.get("image_path", "")
|
|
46
|
|
|
47
|
def get_output_dir(self) -> str:
|
|
48
|
"""Return the directory for output results."""
|
|
49
|
return self.config.get("output_dir", "Results")
|
|
50
|
|
|
51
|
def get_preview(self) -> bool:
|
|
52
|
"""Return the preview flag."""
|
|
53
|
return self.config.get("preview", False)
|