Fusion/UE4_ConvertTextureFiles.py
boo3 b01a970ceb Finished Polishing
- Finished the read me
- Added support for UE4
- Fixed hopefully most bugs
2023-11-13 01:51:12 +01:00

44 lines
1.5 KiB
Python

import os
from wand.image import Image
def convert_dds_to_png(input_folder, output_folder):
# Make sure the output folder exists
if not os.path.exists(output_folder):
os.makedirs(output_folder)
# List all files in the input folder
files = os.listdir(input_folder)
# Iterate through each file in the input folder
for file in files:
# Check if the file has a .dds extension
if file.lower().endswith('.dds'):
# Create the input and output file paths
input_path = os.path.join(input_folder, file)
output_path = os.path.join(output_folder, os.path.splitext(file)[0] + '.png')
print(f"Converting {input_path} to {output_path}")
# Convert DDS to PNG
with Image(filename=input_path) as img:
img.compression = "no"
img.save(filename=output_path)
print(f"Conversion complete: {input_path} -> {output_path}")
if __name__ == "__main__":
# Set the source and destination folders
source_folder = 'textures'
destination_folder = 'converted_textures'
print(f"Converting DDS files from {source_folder} to PNG and saving to {destination_folder}")
# Make sure the output folder exists
if not os.path.exists(destination_folder):
os.makedirs(destination_folder)
# Convert all DDS files in the source folder to PNG
convert_dds_to_png(source_folder, destination_folder)
print("Conversion complete.")