Official 5th Annual Mudspike Christmas Flight - discussion thread

I don’t really know what category this fits, so I guess I’ll just post it here.

By the 10th report, I finally stopped manually cropping the black bars from the sides of my X-Plane VR screenshots (those who fly X-Plane in VR will know what I mean).
That was so annoying that I almost went back to 2D.

I made a quick and dirty Python script to do the cropping automatically instead.
For any .png it finds in the specified directory, it checks if the topleft 200 x 200 pixels are completely black, and the total image size is 1920x1080.
If those conditions are both true, it saves a cropped version of the image, which is cropped horizontally from ‘rightlim’ to ‘leftlim’, and it appends _cropped to its name.
The name of the directory is still hard-coded so you’ll have to edit the text.

It uses Pathlib so I think you need Python 3.4 or higher. I use 3.7, and am fairly sure it should also work with 3.6. It also uses pillow and numpy, which are both part of the standard Anaconda install.
The forum doesn’t allow me to upload it with its original extension (.py) so I put .txt behind the filename. Remove that part so it ends in .py and you can use it.

I know it’s dirty, but I still want to share, since it took me a bit longer than expected to get it to work. This should save you some time if you want to do something similar.

autocrop_vr_shots.py.txt (945 Bytes)

4 Likes