im looking for DDS libraries that can create {bc3 rgba 8 bpp DXT5: interpolated alpha" + genarated mipmaps}
PIL can create .dds but limited output
PYDDS can not save to .DDS
thx for any help
This works as i want but i can not use WAND as i need a standalone .exe when done, so i can share the app.
import os
from wand.image import Image
def convert_png_to_dds():
# Get the current working directory
input_dir = os.getcwd()
output_dir = os.path.join(input_dir, "dds_output") # Output in a subfolder
# Create output directory if it doesn't exist
os.makedirs(output_dir, exist_ok=True)
# Iterate over all files in the current directory
for filename in os.listdir(input_dir):
if filename.endswith('.png'):
input_path = os.path.join(input_dir, filename)
output_filename = f"{os.path.splitext(filename)[0]}.dds"
output_path = os.path.join(output_dir, output_filename)
# Convert PNG to DDS
with Image(filename=input_path) as img:
img.compression = 'dxt5' # Set compression to DXT5
img.mipmaps = True # Generate mipmaps
img.save(filename=output_path)
print(f"Converted: {input_path} to {output_path}")
if __name__ == "__main__":
convert_png_to_dds()
Just as an FYI encase any other modders find this as next to no info is available for this.
Solved it using texconv.exe from
https://github.com/microsoft/DirectXTex/wiki/Texconv
.dds are to be created for World of Tanks.
The below script will convert all .png in the script folder to.dds in /dds_output/
import os
import subprocess
# Set the output directory
output_dir = 'dds_output'
# Create the output directory if it doesn't exist
if not os.path.exists(output_dir):
os.makedirs(output_dir)
# Iterate over all PNG files in the current directory
for filename in os.listdir('.'):
if filename.endswith('.png'):
# Prepare the command to convert PNG to BC3 DXT5 with mipmaps
input_file = filename
output_file = os.path.join(output_dir, f'{os.path.splitext(filename)[0]}.dds')
# Command to run Texconv
command = [
'Texconv.exe', # Change this to the path if Texconv.exe is not in the same folder
'-f', 'dxt5', # Set compression format: DXT5 (BC3, for RGBA images)
'-m', '9', # Generate 9 levels of mipmaps
'-o', output_dir, # Output directory
'--separate-alpha', #separate alpha
input_file # Input file
]
# Run the command
print(f'Converting {input_file} to {output_file}...')
subprocess.run(command)
print('Conversion completed!')