from PIL import Image, ImageEnhance
import requests
from io import BytesIO
# Load your image (update the path if needed)
base_image = Image.open("Screenshot_20250814_101245.jpg").convert("RGBA")
# Load CapCut logo (transparent PNG from web)
logo_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/6/6b/CapCut_Logo.svg/512px-CapCut_Logo.svg.png"
response = requests.get(logo_url)
logo_image = Image.open(BytesIO(response.content)).convert("RGBA")
# Resize logo to medium size (15% of image width)
base_width, base_height = base_image.size
logo_scale = 0.15
new_logo_width = int(base_width * logo_scale)
aspect_ratio = logo_image.height / logo_image.width
new_logo_height = int(new_logo_width * aspect_ratio)
logo_resized = logo_image.resize((new_logo_width, new_logo_height), Image.LANCZOS)
# Set opacity to 60%
alpha = logo_resized.split()[3]
alpha = ImageEnhance.Brightness(alpha).enhance(0.6)
logo_resized.putalpha(alpha)
# Position logo in bottom-right corner
position = (base_width - new_logo_width - 10, base_height - new_logo_height - 10)
# Paste logo onto original image
combined = base_image.copy()
combined.paste(logo_resized, position, logo_resized)
# Save the result
combined.save("edited_with_capcut_logo.png")
print("✅ Saved as 'edited_with_capcut_logo.png'")