Arnie Commentary is a Python based bot which procedurally finds and captions images in the style of an Arnold Schwarzenegger DVD commentary.
The bot first selects a random Arnold Scwarzenegger movie from a list of all his movies and uses Movie_Title + " Arnold Schwarzenegger Sceencap" as a Bing image API query.
Next, it runs OCR locally using Tesseract - if more than a couple of words are detected the image is deleted and it starts over.
The image is then posted to Microsoft Project Oxford Describe Endpoint and a basic description is returned (usually).
Next it uses ImageMagick to check the orientation. If its not landscape, again it's deleted and starts over.
I opted to use some simple reGexes to replace "Arnold Schwarzenegger" with me and a few other simple embellishments to try to make it sound more "Arnie", but it's not actually doing NLP on the returned description.
Next it uses the textwrap
python library to do word wrapping (inserting \n
in the right places to fit on the background image)
-
Last parts are all done in Image Magick:
- Resize the source image.
- Extend a black background around source image with North gravity.
- Composite a little transparent png of Arnie with SouthWest gravity.
- Add the description to the image in yellow using the Alte Haas Grotesk font with a semi-transparent background.
-
The final image is posted to Twitter via Tweepy, then to Tumblr via PyTumblr:
The Twitter interface accepts input images via streaming listener and runs them through the same process...