|
18 | 18 |
|
19 | 19 | FONT = ImageFont.truetype("./fonts/UbuntuMono-Regular.ttf", 24)
|
20 | 20 |
|
21 |
| -# ENABLE_INFO_ON_IMAGE = False |
| 21 | +ENABLE_INFO_ON_IMAGE = True |
22 | 22 |
|
23 | 23 |
|
24 | 24 | def main():
|
@@ -52,8 +52,8 @@ def main():
|
52 | 52 |
|
53 | 53 | img = Image.open(img_path)
|
54 | 54 | img = crop_img(img, top_left, bottom_right)
|
55 |
| - # if ENABLE_INFO_ON_IMAGE: |
56 |
| - # img = add_img_info(img, file_name) |
| 55 | + if ENABLE_INFO_ON_IMAGE: |
| 56 | + img = add_img_info(img, file_name) |
57 | 57 |
|
58 | 58 | if not os.path.exists(OUTPUT_DIR):
|
59 | 59 | os.mkdir(OUTPUT_DIR)
|
@@ -117,20 +117,20 @@ def get_template() -> cv.Mat:
|
117 | 117 | return cv.imread(template_path, 0)
|
118 | 118 |
|
119 | 119 |
|
120 |
| -# def add_img_info(img: Image, info_text: str, info_section_height: int = 35) -> Image: |
121 |
| -# """ |
122 |
| -# Add a section at the top of the image with space to add some |
123 |
| -# extra text. |
124 |
| -# """ |
| 120 | +def add_img_info(img: Image, info_text: str, info_section_height: int = 35) -> Image: |
| 121 | + """ |
| 122 | + Add a section at the top of the image with space to add some |
| 123 | + extra text. |
| 124 | + """ |
125 | 125 |
|
126 |
| -# dimensions = (img.width, img.height + info_section_height) |
127 |
| -# new_img = Image.new("RGBA", dimensions, "black") |
128 |
| -# new_img.paste(img, (0, info_section_height)) |
| 126 | + dimensions = (img.width, img.height + info_section_height) |
| 127 | + new_img = Image.new("RGBA", dimensions, "black") |
| 128 | + new_img.paste(img, (0, info_section_height)) |
129 | 129 |
|
130 |
| -# d = ImageDraw.Draw(new_img) |
131 |
| -# d.text((10, 5), info_text, font=FONT, fill="lightgray") |
| 130 | + d = ImageDraw.Draw(new_img) |
| 131 | + d.text((10, 5), info_text, font=FONT, fill="lightgray") |
132 | 132 |
|
133 |
| -# return new_img |
| 133 | + return new_img |
134 | 134 |
|
135 | 135 |
|
136 | 136 | def crop_img(img: Image, top_left: tuple[int, int], bottom_right: tuple[int, int]) -> Image:
|
|
0 commit comments