Bypass version check if it fails; fix caption image size

pull/1873/head
KyleBoyer 2 years ago
parent 5fa8f136a1
commit aa1275865d

@ -38,6 +38,9 @@ storymodemethod= { optional = true, default = 1, example = 1, explanation = "Sty
storymode_max_length = { optional = true, default = 1000, example = 1000, explanation = "Max length of the storymode video in characters. 200 characters are approximately 50 seconds.", type = "int", nmin = 1, oob_error = "It's very hard to make a video under a second." }
resolution_w = { optional = false, default = 1080, example = 1440, explantation = "Sets the width in pixels of the final video" }
resolution_h = { optional = false, default = 1920, example = 2560, explantation = "Sets the height in pixels of the final video" }
text_size = { optional = false, default = 56, example = 75, explantation = "Sets the font size for the captions" }
text_padding = { optional = false, default = 5, example = 10, explantation = "Sets the line spacing for the captions" }
text_wrap = { optional = false, default = 30, example = 40, explantation = "Sets the number of characters per line, before it is wrapped to another line" }
zoom = { optional = true, default = 1, example = 1.1, explanation = "Sets the browser zoom level. Useful if you want the text larger.", type = "float", nmin = 0.1, nmax = 2, oob_error = "The text is really difficult to read at a zoom level higher than 2" }
[settings.background]

@ -3,6 +3,8 @@ import textwrap
import os
import json
from utils import settings
from PIL import Image, ImageDraw, ImageFont
from rich.progress import track
from TTS.engine_wrapper import process_text
@ -72,7 +74,7 @@ def draw_multiple_line_text(
y += line_height + padding
def imagemaker(theme, reddit_obj: dict, txtclr, padding=5, transparent=False) -> None:
def imagemaker(theme, reddit_obj: dict, txtclr, transparent=False) -> None:
"""
Render Images for video
"""
@ -81,24 +83,25 @@ def imagemaker(theme, reddit_obj: dict, txtclr, padding=5, transparent=False) ->
id = re.sub(r"[^\w\s-]", "", reddit_obj["thread_id"])
if transparent:
font = ImageFont.truetype(os.path.join("fonts", "Roboto-Bold.ttf"), 100)
tfont = ImageFont.truetype(os.path.join("fonts", "Roboto-Bold.ttf"), 100)
font = ImageFont.truetype(os.path.join("fonts", "Roboto-Bold.ttf"), int(settings.config["settings"]["text_size"])) # changed
tfont = ImageFont.truetype(os.path.join("fonts", "Roboto-Bold.ttf"), int(settings.config["settings"]["text_size"])) # changed
else:
tfont = ImageFont.truetype(os.path.join("fonts", "Roboto-Bold.ttf"), 100) # for title
font = ImageFont.truetype(os.path.join("fonts", "Roboto-Regular.ttf"), 100)
size = (1920, 1080)
tfont = ImageFont.truetype(os.path.join("fonts", "Roboto-Bold.ttf"), int(settings.config["settings"]["text_size"])) # for title # changed
font = ImageFont.truetype(os.path.join("fonts", "Roboto-Regular.ttf"), int(settings.config["settings"]["text_size"])) # changed
size = (int(settings.config["settings"]["resolution_w"]), int(settings.config["settings"]["resolution_h"]))
image = Image.new("RGBA", size, theme)
# for title
draw_multiple_line_text(image, title, tfont, txtclr, padding, wrap=30, transparent=transparent)
draw_multiple_line_text(image, perform_text_replacements(title), tfont, txtclr, int(settings.config["settings"]["text_padding"]), wrap=int(settings.config["settings"]["text_wrap"]), transparent=transparent)
image.save(f"assets/temp/{id}/png/title.png")
for idx, text in track(enumerate(texts), "💬 Rendering captions...", total=len(texts)):
image = Image.new("RGBA", size, theme)
text = process_text(text, False)
draw_multiple_line_text(image, perform_text_replacements(text), font, txtclr, padding, wrap=30, transparent=transparent)
draw_multiple_line_text(image, perform_text_replacements(text), font, txtclr, int(settings.config["settings"]["text_padding"]), wrap=int(settings.config["settings"]["text_wrap"]), transparent=transparent)
image.save(f"assets/temp/{id}/png/img{idx}.png")
print_substep("Captions rendered successfully!", style="bold green")

@ -4,6 +4,7 @@ from utils.console import print_step
def checkversion(__VERSION__: str):
try:
response = requests.get(
"https://api.github.com/repos/elebumm/RedditVideoMakerBot/releases/latest"
)
@ -19,3 +20,5 @@ def checkversion(__VERSION__: str):
print_step(
f"Welcome to the test version ({__VERSION__}) of the bot. Thanks for testing and feel free to report any bugs you find."
)
except:
pass

Loading…
Cancel
Save