From 589fd4d50b675c069e0a8a3d8fb78d02f5cbf4a9 Mon Sep 17 00:00:00 2001 From: Leslie Van Date: Fri, 4 Aug 2023 23:30:47 +0800 Subject: [PATCH 1/3] version change # --- main.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.spec b/main.spec index 9f7429c..651ae76 100644 --- a/main.spec +++ b/main.spec @@ -46,5 +46,5 @@ coll = COLLECT( strip=False, upx=True, upx_exclude=[], - name='semi-utils-build1516', + name='semi-utils-build1518', ) From 86fccb13f049d9b914cc13a375f7fca101126e22 Mon Sep 17 00:00:00 2001 From: Leslie Van Date: Fri, 4 Aug 2023 23:33:13 +0800 Subject: [PATCH 2/3] add exiftool detection --- utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils.py b/utils.py index 1796ace..646a7c0 100644 --- a/utils.py +++ b/utils.py @@ -1,8 +1,8 @@ import logging import platform import re +import shutil import subprocess -import unicodedata from pathlib import Path from PIL import Image @@ -14,6 +14,9 @@ if platform.system() == 'Windows': EXIFTOOL_PATH = Path('./exiftool/exiftool.exe') ENCODING = 'gbk' +elif shutil.which('exiftool') is not None: + EXIFTOOL_PATH = shutil.which('exiftool') + ENCODING = 'utf-8' else: EXIFTOOL_PATH = Path('./exiftool/exiftool') ENCODING = 'utf-8' From 95069010ef7b96a3cf99c8a6389ac284a08529a3 Mon Sep 17 00:00:00 2001 From: Leslie Van Date: Sat, 5 Aug 2023 00:24:53 +0800 Subject: [PATCH 3/3] append config item # MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DATE_FILENAME_NAME: 日期 + 文件名 DATETIME_FILENAME_VALUE: 日期时间 + 文件名 --- entity/image_container.py | 54 ++++++++++++++++----------------------- enums/constant.py | 4 +++ init.py | 29 +++------------------ 3 files changed, 29 insertions(+), 58 deletions(-) diff --git a/entity/image_container.py b/entity/image_container.py index 748e1e9..7fdc377 100644 --- a/entity/image_container.py +++ b/entity/image_container.py @@ -9,19 +9,7 @@ from dateutil import parser from entity.config import ElementConfig -from enums.constant import CAMERA_MAKE_CAMERA_MODEL_VALUE -from enums.constant import CAMERA_MODEL_LENS_MODEL_VALUE -from enums.constant import CUSTOM_VALUE -from enums.constant import DATETIME_VALUE -from enums.constant import DATE_VALUE -from enums.constant import DEFAULT_VALUE -from enums.constant import FILENAME_VALUE -from enums.constant import LENS_MAKE_LENS_MODEL_VALUE -from enums.constant import LENS_VALUE -from enums.constant import MAKE_VALUE -from enums.constant import MODEL_VALUE -from enums.constant import PARAM_VALUE -from enums.constant import TOTAL_PIXEL_VALUE +from enums.constant import * from utils import calculate_pixel_count from utils import extract_attribute from utils import get_exif @@ -124,9 +112,25 @@ def __init__(self, path: Path): # 水印图片 self.watermark_img = None - self._param_dict[TOTAL_PIXEL_VALUE] = calculate_pixel_count(self.original_width, self.original_height) - self._param_dict[CAMERA_MAKE_CAMERA_MODEL_VALUE] = ' '.join([self.make, self.model]) + self._param_dict[MODEL_VALUE] = self.model + self._param_dict[PARAM_VALUE] = self.get_param_str() + self._param_dict[MAKE_VALUE] = self.make + self._param_dict[DATETIME_VALUE] = self._parse_datetime() + self._param_dict[DATE_VALUE] = self._parse_date() + self._param_dict[LENS_VALUE] = self.lens_model self._param_dict[FILENAME_VALUE] = self.path.name + self._param_dict[TOTAL_PIXEL_VALUE] = calculate_pixel_count(self.original_width, self.original_height) + + self._param_dict[CAMERA_MAKE_CAMERA_MODEL_VALUE] = ' '.join( + [self._param_dict[MAKE_VALUE], self._param_dict[MODEL_VALUE]]) + self._param_dict[LENS_MAKE_LENS_MODEL_VALUE] = ' '.join( + [self.lens_make, self._param_dict[LENS_VALUE]]) + self._param_dict[CAMERA_MODEL_LENS_MODEL_VALUE] = ' '.join( + [self._param_dict[MODEL_VALUE], self._param_dict[LENS_VALUE]]) + self._param_dict[DATE_FILENAME_VALUE] = ' '.join( + [self._param_dict[DATE_VALUE], self._param_dict[FILENAME_VALUE]]) + self._param_dict[DATETIME_FILENAME_VALUE] = ' '.join( + [self._param_dict[DATETIME_VALUE], self._param_dict[FILENAME_VALUE]]) def get_height(self): return self.get_watermark_img().height @@ -171,25 +175,11 @@ def get_attribute_str(self, element: ElementConfig) -> str: if element is None or element.get_name() == '': return '' - if element.get_name() == MODEL_VALUE: - return self.model - elif element.get_name() == PARAM_VALUE: - return self.get_param_str() - elif element.get_name() == MAKE_VALUE: - return self.make - elif element.get_name() == DATETIME_VALUE: - return self._parse_datetime() - elif element.get_name() == DATE_VALUE: - return self._parse_date() - elif element.get_name() == LENS_VALUE: - return self.lens_model - elif element.get_name() == CUSTOM_VALUE: + if element.get_name() == CUSTOM_VALUE: self.custom = element.get_value() return self.custom - elif element.get_name() == CAMERA_MODEL_LENS_MODEL_VALUE: - return ' '.join([self.model, self.lens_model]) - elif element.get_name() == LENS_MAKE_LENS_MODEL_VALUE: - return ' '.join([self.lens_make, self.lens_model]) + elif element.get_name() in self._param_dict: + return self._param_dict[element.get_name()] else: return '' diff --git a/enums/constant.py b/enums/constant.py index ddbc9d7..1a34d16 100644 --- a/enums/constant.py +++ b/enums/constant.py @@ -24,6 +24,10 @@ CAMERA_MAKE_CAMERA_MODEL_VALUE = 'CameraMake_CameraModel' FILENAME_NAME = '文件名' FILENAME_VALUE = 'Filename' +DATE_FILENAME_NAME = '日期 + 文件名(eg. 2023-01-01 DXO_0001.jpg)' +DATE_FILENAME_VALUE = 'Date_Filename' +DATETIME_FILENAME_NAME = '日期时间 + 文件名(eg. 2023-01-01 12:00 DXO_0001.jpg)' +DATETIME_FILENAME_VALUE = 'Datetime_Filename' LOCATION_LEFT_TOP = 'left_top' LOCATION_LEFT_BOTTOM = 'left_bottom' diff --git a/init.py b/init.py index 5e87498..dcc6963 100644 --- a/init.py +++ b/init.py @@ -19,32 +19,7 @@ from entity.image_processor import WatermarkProcessor from entity.image_processor import WatermarkRightLogoProcessor from entity.menu import * -from enums.constant import CAMERA_MAKE_CAMERA_MODEL_NAME -from enums.constant import CAMERA_MAKE_CAMERA_MODEL_VALUE -from enums.constant import CAMERA_MODEL_LENS_MODEL_NAME -from enums.constant import CAMERA_MODEL_LENS_MODEL_VALUE -from enums.constant import CUSTOM_NAME -from enums.constant import CUSTOM_VALUE -from enums.constant import DATETIME_NAME -from enums.constant import DATETIME_VALUE -from enums.constant import DATE_NAME -from enums.constant import DATE_VALUE -from enums.constant import FILENAME_NAME -from enums.constant import FILENAME_VALUE -from enums.constant import LENS_MAKE_LENS_MODEL_NAME -from enums.constant import LENS_MAKE_LENS_MODEL_VALUE -from enums.constant import LENS_NAME -from enums.constant import LENS_VALUE -from enums.constant import MAKE_NAME -from enums.constant import MAKE_VALUE -from enums.constant import MODEL_NAME -from enums.constant import MODEL_VALUE -from enums.constant import NONE_NAME -from enums.constant import NONE_VALUE -from enums.constant import PARAM_NAME -from enums.constant import PARAM_VALUE -from enums.constant import TOTAL_PIXEL_NAME -from enums.constant import TOTAL_PIXEL_VALUE +from enums.constant import * import logging @@ -197,6 +172,8 @@ def from_processor(processor: ProcessorComponent): ElementItem(TOTAL_PIXEL_NAME, TOTAL_PIXEL_VALUE), ElementItem(CAMERA_MAKE_CAMERA_MODEL_NAME, CAMERA_MAKE_CAMERA_MODEL_VALUE), ElementItem(FILENAME_NAME, FILENAME_VALUE), + ElementItem(DATE_FILENAME_NAME, DATE_FILENAME_VALUE), + ElementItem(DATETIME_FILENAME_NAME, DATETIME_FILENAME_VALUE), ] # 菜单位置与菜单项的映射