Food is one of the worst serial killers
It was late spring and we were trying to finish all our projects before summer. When summer approaches, you know what to do. Throw a summer party.
I was in charge of table logistics. A party planner came up with the ingenious idea of making the place cards photos of the guests. I was also told to create separate signs for food intolerances.
Some people are lactose intolerant, some are allergic to gluten, and some people die from eating shrimp.
Since I’m a Python geek, I wanted to see if I could combine the two. What if we created place cards with allergies already baked into them?
So I did just that.
Thankfully, I was able to get the best starting point anyone could want. The person who collected all the data and photos created a nice spreadsheet.
There were three columns — name
, filename
of the photo, and allergies
. The example in this story is anonymous and the photo has been replaced with his AI-generated photo.
I started by sketching what the result would look like and writing some pseudo code. The actual code is likely to change considerably once you start programming, but it’s good to treat it as a sketch.
'''
fetch the spreadsheet entries:- filenames
- allergies
We don't really care about the names because the photo is their way of seeing
where they are seated.
define a folder with the icons for the allergies.
calculate the size of the images. We want to make sure the watermark
ratio is the same so we get some consistency no matter the image size.
use pillow to overlay the images.
save new image with the filename plus a suffix
If no allergies,copy over the photos.
'''
The icons must be consistent across all place cards, so we need to calculate the percentage they cover. I would like to add it to the bottom right of the photo. (If you’re up for the challenge…