import os
from PIL import Image

def convert_to_32bit(file_path):
    try:
        # Open the image
        image = Image.open(file_path)

        # Convert to 32-bit color depth
        if image.mode != 'RGBA':
            image = image.convert('RGBA')

        # Save the converted image
        converted_file_path = file_path.replace('.png', '_32bit.png')
        image.save(converted_file_path)
        
        print(f"Conversion complete for '{file_path}'. Saved as '{converted_file_path}'")
    except Exception as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    script_directory = os.path.dirname(os.path.realpath(__file__))
    png_files = [f for f in os.listdir(script_directory) if f.lower().endswith('.png')]

    if not png_files:
        print("No .png files found in the script directory.")
    else:
        for file_name in png_files:
            file_path = os.path.join(script_directory, file_name)
            convert_to_32bit(file_path)
