Exemplo n.º 1
0
    def extension(self, value):
        assertion.assert_valid_type(value, str)
        assertion.assert_valid_extension(value)

        self._extension = value
        self._path = Path(
            os.path.join(self._path.parents[0], self._name + self._extension))
Exemplo n.º 2
0
    def path(self, value: Path or str):
        if isinstance(value, str):
            value = Path(value)

        assertion.assert_valid_type(value, Path)

        self._path = value
        self._name = self._path.stem
        self._extension = self._path.suffix
Exemplo n.º 3
0
    def __init__(self, image_path: str):
        assertion.assert_valid_type(image_path, str)
        assertion.assert_valid_image_path(image_path)

        self._path = Path(image_path)
        self._name = self.path.stem
        self._extension = self.path.suffix

        self.image = Image.open(fp=image_path)
        self.resolution = self.image.size
Exemplo n.º 4
0
    def export_csv(
            self,
            image_path: str,
            destination_path: str,
            write_mode: selection.WriteMode = selection.WriteMode.Append):
        assertion.assert_valid_type(destination_path, str)
        assertion.assert_valid_csv_path(destination_path)
        assertion.assert_valid_type(write_mode, selection.WriteMode)

        csv_string = self.to_csv(image_path).strip() + "\n"

        if write_mode is selection.WriteMode.Overwrite:
            write_mode = "w+"
        elif write_mode is selection.WriteMode.Append:
            write_mode = "a+"

        with open(destination_path, mode=write_mode) as file:
            file.write(csv_string)