Feat: use ration in one_centered

This commit is contained in:
Bertrand Benjamin 2022-07-05 07:13:04 +02:00
parent 27e5c52548
commit 58edb87ebc
2 changed files with 6 additions and 6 deletions

View File

@ -15,7 +15,8 @@ photobook.set_auto_page_break(False)
photobook.set_fig_folder("textures")
photobook.one_centered("eugene.jpg", "one_centered default")
photobook.one_centered("eugene.jpg", "one_centered part_of_text=2", part_of_text=2)
photobook.one_centered("eugene.jpg", "")
photobook.one_centered("eugene.jpg", "one_centered text_ratio=1, img_ratio=1", text_ratio=1, img_ratio=1)
photobook.output(dest)

View File

@ -109,15 +109,14 @@ class Photobook(FPDF):
self,
img,
text="",
part_of_text=6,
img_ratio=5,
text_ratio=1,
):
"""Display the picture centered with text below"""
self.add_page()
if text == "":
text_size = (0, 0)
else:
text_size = (self.epw, (self.eph - self.sep) / part_of_text - self.sep)
total_ratio = img_ratio + text_ratio
text_size = (self.epw, (self.eph - self.sep) * text_ratio / total_ratio - self.sep)
img_size = (self.epw, self.eph - text_size[1])
img_dest = self.img_process(img, img_size)