Skip to content

Commit

Permalink
Merge pull request #63 from leslievan/build1518
Browse files Browse the repository at this point in the history
Build1518
  • Loading branch information
leslievan authored Aug 4, 2023
2 parents cc734a7 + 7560664 commit f9e09f6
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 60 deletions.
54 changes: 22 additions & 32 deletions entity/image_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ''

Expand Down
4 changes: 4 additions & 0 deletions enums/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
29 changes: 3 additions & 26 deletions init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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),
]

# 菜单位置与菜单项的映射
Expand Down
2 changes: 1 addition & 1 deletion main.spec
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ coll = COLLECT(
strip=False,
upx=True,
upx_exclude=[],
name='semi-utils-build1517',
name='semi-utils-build1518',
)
5 changes: 4 additions & 1 deletion utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging
import platform
import re
import shutil
import subprocess
import unicodedata
from pathlib import Path

from PIL import Image
Expand All @@ -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'
Expand Down

0 comments on commit f9e09f6

Please sign in to comment.