Inventory items max height
This commit is contained in:
31
scripts/resize.py
Executable file
31
scripts/resize.py
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from PIL import Image
|
||||
import argparse, os
|
||||
|
||||
#ex: ./resize.py ../gymkhana/items/inventory/assets
|
||||
|
||||
parser = argparse.ArgumentParser(description='Resize images from folder.')
|
||||
parser.add_argument('folder', metavar='SOURCE_FOLDER', type=str,
|
||||
help='source folder')
|
||||
|
||||
args = parser.parse_args()
|
||||
maxHeight = 115
|
||||
|
||||
for file in os.listdir(args.folder):
|
||||
if file.endswith("png"):
|
||||
|
||||
img = Image.open(os.path.join(args.folder,file))
|
||||
if img.height > maxHeight:
|
||||
print("Processing " + file)
|
||||
hpercent = (maxHeight / float(img.size[1]))
|
||||
wsize = int((float(img.size[0]) * float(hpercent)))
|
||||
img = img.resize((wsize, maxHeight))
|
||||
img.save(os.path.join(args.folder,file))
|
||||
|
||||
|
||||
#img = Image.open('fullsized_image.jpg')
|
||||
#wpercent = (basewidth / float(img.size[0]))
|
||||
#hsize = int((float(img.size[1]) * float(wpercent)))
|
||||
#img = img.resize((basewidth, hsize), Image.ANTIALIAS)
|
||||
#img.save('resized_image.jpg')
|
||||
Reference in New Issue
Block a user