Outcrop.py

July 3, 2022

For posterity: here’s a little Python script I wrote that takes an image file and pads it with white space (or whatever color) to make it have a certain aspect ratio. Basically it turns this:

into this, which is 8x10:

I was trying to print some photos on photo-printing websites and got very annoyed that they (Shutterly, NationsPhotoLab, etc) will happily try to print a photo in any aspect ratio you choose, but will mindlessly crop the photo to that size when you upload it instead of letting you position it in the frame the way you want. It’s a perfectly reasonably request to print an 8x8 photo on 8x10 paper with blank space around it! And yet somehow it is hard. (Although it generally looks better to mount it with matboard).

(This Wirecutter article even complains about the same thing, sheesh.)

I mention it here because I originally made this blog in order to ‘save my work’, that is, to stave off the feeling that I had produced nothing in my free time, at a time when I was spending each unemployed day dredging up obscure math papers and wrestling with leftover confusions from undergraduate physics, with little to show for it. This isn’t that kind of work, but it still seems more likely to end up mattering again if I write about it here, so I am.