Last active
March 9, 2026 07:21
-
-
Save jsoctocat/0dd5af1e8667ca45ee3e70c30e50cc78 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| from PIL import Image | |
| # Define your source and destination folders | |
| input_dir = "./minimap_data" | |
| output_dir = f"{input_dir}_processed" | |
| os.makedirs(output_dir, exist_ok=True) | |
| # Loop through all files in the directory | |
| for filename in os.listdir(input_dir): | |
| if filename.lower().endswith(".dds"): | |
| try: | |
| # Construct full file paths | |
| img_path = os.path.join(input_dir, filename) | |
| # Create new filename by replacing extension | |
| png_name = os.path.splitext(filename)[0] + ".png" | |
| output_path = os.path.join(output_dir, png_name) | |
| # Open and convert | |
| with Image.open(img_path) as img: | |
| # DDS often uses RGBA; ensure compatibility | |
| img.convert("RGBA")\ | |
| .save(output_path, "PNG", optimize=True) | |
| print(f"Converted: {filename} -> {png_name}") | |
| except Exception as e: | |
| print(f"Failed to convert {filename}: {e}") | |
| print("Batch processing complete.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment