Added Texture Folder + Scripts
This commit is contained in:
34
Texturing/OptimizeTextures/optimize_textures.py
Normal file
34
Texturing/OptimizeTextures/optimize_textures.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from unittest import skip
|
||||
from PIL import Image
|
||||
import sys
|
||||
import os
|
||||
|
||||
if len(sys.argv) < 1:
|
||||
print("Please provide the input files.")
|
||||
sys.exit(1)
|
||||
|
||||
inputTexs = sys.argv
|
||||
|
||||
if not os.path.exists(os.path.join(os.path.dirname(inputTexs[1]),"optimized")):
|
||||
os.mkdir(os.path.join(os.path.dirname(inputTexs[1]),"optimized"))
|
||||
|
||||
export_path = os.path.join(os.path.dirname(inputTexs[1]),"optimized")
|
||||
|
||||
#export_path = os.mkdir(os.path.join(os.path.dirname(inputTexs[1]),"optimized"))
|
||||
#print (Input_filepath)
|
||||
#print(inputTexs[1])
|
||||
|
||||
for i in range(1,len(inputTexs),1):
|
||||
currentTex = Image.open(inputTexs[i])
|
||||
|
||||
if currentTex.size <= (2048,2048):
|
||||
print (currentTex + "is already smaller than 2048x2048")
|
||||
continue
|
||||
|
||||
|
||||
# downsize the image with an LANCZOS filter (gives the highest quality)
|
||||
resizedTex = currentTex.resize((2048,2048),Image.LANCZOS)
|
||||
|
||||
resizedTex.save(str(export_path) + "\\" + os.path.basename(inputTexs[i]), optimize=True, quality=95)
|
||||
|
||||
print("Textures successfully resized!")
|
||||
Reference in New Issue
Block a user