#!/usr/bin/env python
# -*- coding: utf-8 -*-

import json

class ConfigReader:
    """
    ConfigReader loads configuration settings from a JSON file.
    It now uses a single base path for input images.
    """

    def __init__(self, json_path: str):
        """
        Initialize the ConfigReader with the path to the configuration file.
        :param json_path: Path to the JSON configuration file
        """
        self.json_path = json_path
        self.config = None
        self.load_config()

    def load_config(self):
        """Load configuration data from the JSON file."""
        try:
            with open(self.json_path, 'r', encoding='utf-8') as f:
                self.config = json.load(f)
        except FileNotFoundError:
            raise FileNotFoundError(f"Configuration file not found: {self.json_path}")
        except json.JSONDecodeError as e:
            raise ValueError(f"Error decoding JSON: {e}")

    def get_blend_width(self) -> int:
        """Return the blending width."""
        return self.config.get("blend_width", 200)

    def get_gamma_value(self) -> float:
        """Return the gamma correction value."""
        return self.config.get("gamma_value", 1.0)

    def get_blend_method(self) -> str:
        """Return the blending method (e.g., 'cosine', 'linear')."""
        return self.config.get("blend_method", "linear")

    def get_image_path(self) -> str:
        """Return the base directory of the input images."""
        return self.config.get("image_path", "")

    def get_output_dir(self) -> str:
        """Return the directory for output results."""
        return self.config.get("output_dir", "Results")
        
    def get_preview(self) -> bool:
        """Return the preview flag."""
        return self.config.get("preview", False)