max 128 inventory images

This commit is contained in:
2023-08-26 16:56:57 +02:00
parent a3cb90b96b
commit 916c4003be
19 changed files with 12 additions and 2 deletions

View File

@@ -1,5 +1,8 @@
#!/usr/bin/env python3
#
# Example command: ./generate-items.py /home/`whoami`/Nextcloud/gynkhana/items/ ../gymkhana/items/inventory/ turno_cocina
#
import shutil, sys, glob, os, math
from pathlib import Path
from PIL import Image
@@ -46,8 +49,15 @@ def generateImage(inputFile, baseName):
originalImage = Image.open(inputFile)
scale = 0.15
newImage = originalImage.resize((math.ceil(originalImage.width * scale),math.ceil(originalImage.height * scale)))
biggerSide = originalImage.width
if(originalImage.width < originalImage.height):
biggerSide = originalImage.height
scale = 128 / biggerSide
#scale = 0.15
newImage = originalImage.resize((math.floor(originalImage.width * scale),math.floor(originalImage.height * scale)))
newImageOutputPath = outputDir + "assets/" + baseName + ".png"
print(f"{bcolors.OKCYAN}Image:{bcolors.ENDC} {newImageOutputPath} {bcolors.OKGREEN}generated.{bcolors.ENDC}")
newImage.save(newImageOutputPath)