Skip to content

Commit 695eb27

Browse files
committed
readd the feature to add the filename to the top of the output image
1 parent 0643baa commit 695eb27

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

main.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
FONT = ImageFont.truetype("./fonts/UbuntuMono-Regular.ttf", 24)
2020

21-
# ENABLE_INFO_ON_IMAGE = False
21+
ENABLE_INFO_ON_IMAGE = True
2222

2323

2424
def main():
@@ -52,8 +52,8 @@ def main():
5252

5353
img = Image.open(img_path)
5454
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)
5757

5858
if not os.path.exists(OUTPUT_DIR):
5959
os.mkdir(OUTPUT_DIR)
@@ -117,20 +117,20 @@ def get_template() -> cv.Mat:
117117
return cv.imread(template_path, 0)
118118

119119

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+
"""
125125

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))
129129

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")
132132

133-
# return new_img
133+
return new_img
134134

135135

136136
def crop_img(img: Image, top_left: tuple[int, int], bottom_right: tuple[int, int]) -> Image:

0 commit comments

Comments
 (0)