fixed PIL textsize versus textlength

This commit is contained in:
LonicaMewinsky
2023-11-27 08:47:18 -06:00
parent 560d6dd875
commit a7895f6114
2 changed files with 3 additions and 5 deletions
+3 -4
View File
@@ -101,11 +101,10 @@ def ImgLabeler(img, text, size=72, color=(255,255,255)):
draw = ImageDraw.Draw(img) draw = ImageDraw.Draw(img)
# Get text size # Get text size
text_size = draw.textsize(text, font=font) text_size = draw.textlength(text, font=font)
# Calculate x, y coordinates of the text # Calculate x, y coordinates of the text
x = (img.width - text_size[0]) / 2 x = (img.width - text_size) / 2
y = (img.height - text_size[1]) / 2 y = (img.height - text_size) / 2
# Position for the text, centered # Position for the text, centered
text_position = (x, y) text_position = (x, y)
-1
View File
@@ -6,7 +6,6 @@ import random
from PIL import Image from PIL import Image
from .. import makeframeutils as mfu from .. import makeframeutils as mfu
device = torch.device("cuda" if torch.cuda.is_available() else "cpu") device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
class BreakFrames: class BreakFrames: