freedoom/graphics/text/image_dimensions.py
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

25 lines
473 B
Python
Executable file

#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
import re
from PIL import Image
def get_image_dimensions(filename):
"""Get image dimensions w x h
Args:
filename: filename of the image
"""
with Image.open(filename) as img:
width, height = img.size
return (width, height)
if __name__ == "__main__":
import sys
x, y = get_image_dimensions(sys.argv[1])
string = "%i %i" % (x, y)
sys.stdout.write(string)