Skip to content

Commit

Permalink
0.93: add focal length info, char validation
Browse files Browse the repository at this point in the history
  • Loading branch information
cyan-io committed Jul 11, 2023
1 parent 8548fb8 commit cbbcaea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

![sample](./readme/sample.jpg)

👆`v0.93`已增加焦距信息

## 使用方式

下载release并解压到任意位置
Expand Down
17 changes: 10 additions & 7 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.92\n\n\thttps://github.com/cyan-io/exif-frame\n\thttps://space.bilibili.com/266211787\n"
"\n Exif-Frame v0.93\n\n\thttps://github.com/cyan-io/exif-frame\n\thttps://space.bilibili.com/266211787\n"
)
print_Y("------------------------------------------------\n")

Expand Down Expand Up @@ -50,24 +50,28 @@ def exec(image_path):
# 获取Exif
exif_data = get_exif_data(image_path)
camera_info = get_camera_info(exif_data)
a, b, c = (
a, b, c, d = (
camera_info.get("FocalLength", DEFAULT_EXIF_MESSAGE),
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)
if DEFAULT_EXIF_MESSAGE in (a, b, c, d)
else "{}mm ISO{} f{} {}".format(int(a), b, c, d)
)
make = camera_info.get("Make")
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)
)

make = get_printalbe_text(make)
text_model = get_printalbe_text(text_model)
text_lens = get_printalbe_text(text_lens)
text_datetime = get_printalbe_text(text_datetime)

# 绘图
image_original = Image.open(image_path).convert("RGBA")
Expand Down Expand Up @@ -112,7 +116,6 @@ def exec(image_path):
position_lens, text_lens, fill=COLOR_GREY, font=font_regular,
)

make = camera_info.get("Make")
try:
logo = Image.open(f"./logo/{make}.png")
width, height = logo.size
Expand Down
3 changes: 3 additions & 0 deletions util.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def get_camera_info(exif_data):
if "LensModel" in exif_data:
camera_info["LensModel"] = exif_data["LensModel"]

if "FocalLength" in exif_data:
camera_info["FocalLength"] = exif_data["FocalLength"]

return camera_info


Expand Down

0 comments on commit cbbcaea

Please sign in to comment.