Search code examples
listphoto

I have a list of 1000 words, I need to make sure that each word is written on a separate picture. how can i automate this?


I attached photo example:

https://i.sstatic.net/f3hvY.jpg

I need to do the same with 1000 words


Solution

  • You can automate with python using the PILL library.

    from PIL import Image, ImageDraw ,ImageFont
     
    words = ['Hello World' , 'Good Morning' , 'Coffee']
    
    for number,word in enumerate(words):
        img = Image.new('RGB', (1000, 1000), color =(0,0,0)) #(0,0,0) means black
        font = ImageFont.truetype("arial.ttf",50)
        d = ImageDraw.Draw(img)
        d.text((400,400), word , font = font,fill=(255,255,255)) #(255,255,255) is white
        img.save(f'pil_text{number}.jpg')
    

    In the above code, you can change the background color, font size, font type, name of file. You can add your word list in 'word' manually or load a file in python. The code will slightly change then depending whats the file you are loading.