Untitled
unknown
plain_text
17 days ago
1.1 kB
3
Indexable
Never
from PIL import Image, ImageFilter def create_instagram_post(bg_img_path, overlay_img_path, output_path): # Open the background image (product image) bg_img = Image.open(bg_img_path) # Resize the background image to 1080x1080 bg_img = bg_img.resize((1080, 1080), Image.ANTIALIAS) # Apply a blur effect to the background bg_img = bg_img.filter(ImageFilter.GaussianBlur(radius=15)) # Open the overlay image overlay_img = Image.open(overlay_img_path) # Resize the overlay image to 720x720 overlay_img = overlay_img.resize((720, 720), Image.ANTIALIAS) # Calculate the position to paste the overlay image (centered) overlay_position = ((1080 - 720) // 2, (1080 - 720) // 2) # Paste the overlay image on top of the background (with transparency) bg_img.paste(overlay_img, overlay_position, overlay_img) # Save the result to the output path bg_img.save(output_path) # Example usage create_instagram_post('product_image.png', 'overlay_image.png', 'instagram_post.png')
Leave a Comment