Skip to content

Commit

Permalink
0.92: make missing exif info configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
cyan-io committed Jul 8, 2023
1 parent e525280 commit 8548fb8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
4 changes: 3 additions & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ font_bold : ./font/NotoSansSC-Bold.otf
# 白边
padding : 120
# 字体大小
font_size : 80
font_size : 80
# 缺省值
default_exif_message : "N/A"
28 changes: 18 additions & 10 deletions index.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

print_Y("------------------------------------------------")
print_Y(
"\n Exif-Frame v0.91\n\n\thttps://github.com/cyan-io/exif-frame\n\thttps://space.bilibili.com/266211787\n"
"\n Exif-Frame v0.92\n\n\thttps://github.com/cyan-io/exif-frame\n\thttps://space.bilibili.com/266211787\n"
)
print_Y("------------------------------------------------\n")

Expand All @@ -37,7 +37,7 @@
)
# 边距
PADDING = int(config.get("padding", 0))

DEFAULT_EXIF_MESSAGE = config.get("default_exif_message", "N/A")

PADDING_LEFT = PADDING
COLOR_BLACK = (0, 0, 0)
Expand All @@ -50,15 +50,23 @@ def exec(image_path):
# 获取Exif
exif_data = get_exif_data(image_path)
camera_info = get_camera_info(exif_data)

text_ise = "ISO{} f{} {}".format(
camera_info.get("ISO", "N/A"),
camera_info.get("FNumber", "N/A"),
camera_info.get("ExposureTime", "N/A"),
a, b, c = (
camera_info.get("ISO", DEFAULT_EXIF_MESSAGE),
camera_info.get("FNumber", DEFAULT_EXIF_MESSAGE),
camera_info.get("ExposureTime", DEFAULT_EXIF_MESSAGE),
)
text_ise = (
DEFAULT_EXIF_MESSAGE
if a == DEFAULT_EXIF_MESSAGE
or b == DEFAULT_EXIF_MESSAGE
or c == DEFAULT_EXIF_MESSAGE
else "ISO{} f{} {}".format(a, b, c)
)
text_model = "{}".format(camera_info.get("Model", DEFAULT_EXIF_MESSAGE))
text_lens = "{}".format(camera_info.get("LensModel", DEFAULT_EXIF_MESSAGE))
text_datetime = "{}".format(
camera_info.get("DateTimeOriginal", DEFAULT_EXIF_MESSAGE)
)
text_model = "{}".format(camera_info.get("Model", "N/A"))
text_lens = "{}".format(camera_info.get("LensModel", "N/A"))
text_datetime = "{}".format(camera_info.get("DateTimeOriginal", "N/A"))
text_lens = get_printalbe_text(text_lens)

# 绘图
Expand Down

0 comments on commit 8548fb8

Please sign in to comment.