alexshelto / reddit_video_maker

This project will find popular Reddit threads and convert them into a text-to-speech videos.
GNU General Public License v3.0
74 stars 13 forks source link

Long text goes outside the image #4

Open GearKite opened 3 years ago

GearKite commented 3 years ago

Longer comments go outside the image like this reply12 reply43

alexshelto commented 3 years ago

Thanks for the issue! This logic is currently in src/utils.py around line 40. in this block of code:

for line in utils.split_string(text, 10):        
     text_dimensions = utils.get_text_dimensions(line, font)   
     x = (image_width - text_dimensions[0]) / 2                      
     draw.text((x, y),line,font=font,fill=(255,255,255))            
     y += 50 # adding 50 pixel buffer to next line

This is an edge case that haddent come up on the demo's I tested this for. I am open to different suggestions on how to alter the code to fix that problem such as multiple images (like a continued page or something). Since it seems like more people are interested in this code after posting it to reddit I am open to hearing the communities ideas for a fix before implementing a change in the code. Feel free to give a suggestion.

alexshelto commented 3 years ago

The logic is now in ImageCreator.py still unchanged.