From my last post where I made a slideshow promo video, I realised how powerful Pillow is. I still have a fair bit of automation to do, so another thing I do a lot of is motivational quotes for Twitter (I am aware they are fucking stupid, but they share well) The breakdown of the components are a background with a filter, the quote, who said it and our logo. Background and Filter To start off I am going to create a folder called quote and add in an image and just name it background.jpg (sourced from Pixabay ). Next I import PIL and open the file. from PIL import Image import os , errno cwd = os.getcwd() image_dir = os.path.join(cwd , 'quote' ) def filterImage (imageFile): im = Image.open(imageFile) im.show() filterImage(os.path.join(image_dir , 'background.jpg' )) Next I need to crop the image. I am going to take the centre portion out of the image to make square. Like so: So I start off with getting the dimensions of the ima
I am in the middle of building an app and need to put together several promo videos for Twitter and Instagram, and man it is boring. So I thought 'how can I automate this process?', so welcome to this post. What I am going for is a selection of images, greyscaled flipping through with our logo on the front. So my approach was to use python, pillow and ffmpeg to build something. This could be disastrous. Images To start a few pre-flight checks, a variable for the test image and to check for/create a processed folder for the final images to go. import os , errno from PIL import Image , ImageFont , ImageDraw testImage = 'test.png' cwd = os.getcwd() image_dir = os.path.join(cwd , 'images' ) default_dir = os.path.join(cwd , 'processed' ) try : os.makedirs(default_dir) except OSError as e: if e.errno != errno.EEXIST: raise I am going to build a function that will do all of the processing, but first going to run on one image b