Downloads · 30 days
0
Admin2023iran/Iran2023
Iran2023 is a machine learning model from Admin2023iran. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
from PIL import Image, ImageDraw, ImageFont import imageio
Downloads · 30 days
0
Access
Public
Updated Dec 6, 2023
Repo size
—
Likes
1
Public
Click a slice to open those files.
Other1.5 KB · 71%
From the Hugging Face model README
from PIL import Image, ImageDraw, ImageFont import imageio
def generate_gif(text, filename, font_size=50, font_path='arial.ttf', fps=15): # Create the font object font = ImageFont.truetype(font_path, font_size)
# Measure the size of the text
text_width, text_height = font.getsize(text)
# Create an image object
image = Image.new('RGB', (text_width, text_height), color='white')
draw = ImageDraw.Draw(image)
# Draw the text
draw.text((0, 0), text, font=font, fill='black')
# Save the image to a list of images
images = [image]
# Create the gif
imageio.mimsave(filename,