Here i found an oldrer code snipped that served as my RnD for a thumbnail application that i made for my studio. This code snipped uses very simple. here is what this snippet does:
We create a new Canvas 512×512, and open another image from our HDD, Resizing the image to desired size, in my case it was 128×128, and i am sure i had a good reason for all these sizes :), we also set the Font that we want to use, here i explicitly copied font file to so opened location, just to avoid some security troubles with Windows folder and all that, we combine our canvas and image together and add text at some location, in red, and as a last step – save this new image somewhere on the disk.
Now, why is this here, often , in production i come about really frequently repeated actions, of assembling some sort of Daily report or something similar, so, if this code is adapted into a very simple structure, you can have a pretty powerful application that allows to save a lot of time in assembly of these assets… really up to your imagination how one could use it.
i want to have this code here for my own reference, and for anyone who is after some ideas for automation.. or what not 🙂
from PIL import Image, ImageFont, ImageDraw font = ImageFont.truetype("C:/arial.ttf", 22) im = Image.new("RGB", (512, 512), "black") im2 = Image.open("c:/1.png") im2 = im2.resize((128,128)) draw = ImageDraw.Draw(im) im.paste(im2, (10,10)) draw.text((100,100), "Hello", font=font, fill=(255,0,0)) im.save("C:/test.jpg")