diff --git a/tools/Texture_Converter.py b/tools/Texture_Converter.py
index d449a90f8..60f9ea76c 100755
--- a/tools/Texture_Converter.py
+++ b/tools/Texture_Converter.py
@@ -8,7 +8,9 @@ __author__ = "Wuzzy"
__license__ = "MIT License"
__status__ = "Development"
-import shutil, csv, os, tempfile, sys, getopt
+import shutil, csv, os, tempfile, sys, getopt, glob
+from PIL import Image
+from collections import Counter
# Helper vars
home = os.environ["HOME"]
@@ -31,7 +33,18 @@ make_texture_pack = True
# If True, prints all copying actions
verbose = False
-PXSIZE = 16
+PXSIZE = None
+
+def detect_pixel_size(directory):
+ sizes = []
+ for filename in glob.glob(directory + '/**/*.png', recursive=True):
+ with Image.open(filename) as img:
+ sizes.append(img.size)
+ if not sizes:
+ return 16 # Default to 16x16 if no PNG files are found
+ most_common_size = Counter(sizes).most_common(1)[0][0]
+ print(f"Autodetected pixel size: {most_common_size[0]}x{most_common_size[1]}")
+ return most_common_size[0]
syntax_help = appname+""" -i [-o