New square backgrounds for @pomological

I’m happy to say I’ve fixed the most frequent complaint I’ve gotten about @pomological: the images, while great, are overwhelmingly in the portrait orientation, making the preview images on many Twitter clients—and especially Twitter.com—kind of lousy.

No more! Beautiful squares on a color hand-picked to match most of the painting backdrops.

To address this, I had to learn a little about pillow, the leading Python image library. Now, when the bot downloads a random image from the watercolors, it draws a new neutral-colored box that’s a little longer than the painting’s longest side, and pastes the thing in the center of that.

The hardest part was ensuring the resulting image was in a format that Twitter can understand—especially because this is one of the handful of things that changed in between Python 2 and 3. But I persevered, and read a lot of documentation, and now it’s live.