Spaces:
No application file
No application file
| from PIL import Image, ImageOps | |
| import numpy as np | |
| # Open the logo | |
| img = Image.open('logo.png') | |
| # Convert to RGBA if not already | |
| img = img.convert('RGBA') | |
| # Get the data | |
| data = np.array(img) | |
| # Separate RGB and Alpha channels | |
| rgb = data[:, :, :3] | |
| alpha = data[:, :, 3] | |
| # Invert RGB channels (255 - value) | |
| inverted_rgb = 255 - rgb | |
| # Combine inverted RGB with original alpha | |
| inverted_data = np.dstack((inverted_rgb, alpha)) | |
| # Create new image | |
| inverted_img = Image.fromarray(inverted_data.astype('uint8'), 'RGBA') | |
| # Save the inverted logo | |
| inverted_img.save('logo-inverted.png') | |
| print("Logo colors inverted successfully! Saved as logo-inverted.png") |