from PIL import Image
# Load the two images
image_path1 = "/mnt/data/file-4eU7vheg59wcVoAv3NUi9h"
image_path2 = "/mnt/data/file-CjJQqi6bFEV9MkLYFScfF3"
image1 = Image.open(image_path1)
image2 = Image.open(image_path2)
# Determine the new image size
new_width = max(image1.width, image2.width)
new_height = image1.height + image2.height
# Create a blank image with a white background
merged_image = Image.new("RGB", (new_width, new_height))
# Paste the images on top of each other
merged_image.paste(image1, (0, 0))
merged_image.paste(image2, (0, image1.height))
# Save the merged image
merged_image_path = "/mnt/data/merged_image.jpg"
merged_image.save(merged_image_path)
merged_image_path