freedoom/graphics/text/rotate
Mike Swanson 6eef9be73a use python3 only for building
Python 2 is very near end-of-life, and Python3-compatible changes to a
few scripts introduced compatibility problems with 2.7 again.  It went
unnoticed for me since my system symlinks "python" to "python3", but
it broke the build on systems where that symlink is still python2.  At
this point in time, I feel it is worth targetting modern Python and
forgetting about 2.7.
2019-09-06 14:43:50 -07:00

27 lines
601 B
Python
Executable file

#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
from PIL import Image
import sys
import os
img = Image.open(sys.argv[1])
img.load()
angle = int(sys.argv[2])
if angle % 90 == 0:
if angle == 90 or angle == -270:
method = Image.ROTATE_90
elif abs(angle) == 180:
method = Image.ROTATE_180
else:
method = Image.ROTATE_270
img2 = img.transpose(method)
else:
img2 = img.rotate(int(sys.argv[2]), 0, True)
img2 = img2.crop()
if os.path.exists(sys.argv[3]): # delete any previous result file
os.remove(sys.argv[3])
img2.save(sys.argv[3])