Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion img2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def main(opt):
cell_height = 12
num_cols = int(width / cell_width)
num_rows = int(height / cell_height)
char_width, char_height = font.getsize(sample_character)
bbox = font.getbbox(sample_character)
char_width = bbox[2] - bbox[0]
char_height = bbox[3] - bbox[1]

out_width = char_width * num_cols
out_height = scale * char_height * num_rows
out_image = Image.new("L", (out_width, out_height), bg_code)
Expand Down
5 changes: 4 additions & 1 deletion img2img_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ def main(opt):
cell_height = 12
num_cols = int(width / cell_width)
num_rows = int(height / cell_height)
char_width, char_height = font.getsize(sample_character)
bbox = font.getbbox(sample_character)
char_width = bbox[2] - bbox[0]
char_height = bbox[3] - bbox[1]

out_width = char_width * num_cols
out_height = scale * char_height * num_rows
out_image = Image.new("RGB", (out_width, out_height), bg_code)
Expand Down
13 changes: 8 additions & 5 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@

def sort_chars(char_list, font, language):
if language == "chinese":
char_width, char_height = font.getsize("制")
bbox = font.getbbox("制")
elif language == "korean":
char_width, char_height = font.getsize("ㅊ")
bbox = font.getbbox("ㅊ")
elif language == "japanese":
char_width, char_height = font.getsize("あ")
bbox = font.getbbox("あ")
elif language in ["english", "german", "french", "spanish", "italian", "portuguese", "polish"]:
char_width, char_height = font.getsize("A")
bbox = font.getbbox("A")
elif language == "russian":
char_width, char_height = font.getsize("A")
bbox = font.getbbox("A")
char_width = bbox[2] - bbox[0]
char_height = bbox[3] - bbox[1]

num_chars = min(len(char_list), 100)
out_width = char_width * len(char_list)
out_height = char_height
Expand Down
5 changes: 4 additions & 1 deletion video2video.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ def main(opt):
cell_height = 12
num_cols = int(width / cell_width)
num_rows = int(height / cell_height)
char_width, char_height = font.getsize("A")
bbox = font.getbbox("A")
char_width = bbox[2] - bbox[0]
char_height = bbox[3] - bbox[1]

out_width = char_width * num_cols
out_height = 2 * char_height * num_rows
out_image = Image.new("L", (out_width, out_height), bg_code)
Expand Down
5 changes: 4 additions & 1 deletion video2video_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ def main(opt):
cell_height = 12
num_cols = int(width / cell_width)
num_rows = int(height / cell_height)
char_width, char_height = font.getsize("A")
bbox = font.getbbox("A")
char_width = bbox[2] - bbox[0]
char_height = bbox[3] - bbox[1]

out_width = char_width * num_cols
out_height = 2 * char_height * num_rows
out_image = Image.new("RGB", (out_width, out_height), bg_code)
Expand Down