from PIL import Image
import numpy as np
# Load the image
image = Image.open("mads2.png").convert("RGBA")
# Convert image to array
data = np.array(image)
# Define white background threshold
r, g, b, a = data[:,:,0], data[:,:,1], data[:,:,2], data[:,:,3]
white_areas = (r > 240) & (g > 240) & (b > 240)
data[white_areas] = [255, 255, 255, 0] # Set white pixels to transparent
# Create new image from modified array
transparent_image = Image.fromarray(data)
# Save the new image
transparent_image.save("connoisseur_logo_transparent.png")