I have searched for this topic of how to merge or concatenate multiple images using python.
from PIL import Image
def get_concat_v():
dst = Image.new('RGB', (im1.width, im1.height + im2.height + im3.height + im4.height))
dst.paste(im1, (0, 0))
dst.paste(im2, (0, im1.height))
dst.paste(im3, (0, im1.height + im2.height))
dst.paste(im4, (0, im1.height + im2.height + im3.height))
return dst
im1 = Image.open('First.png')
im2 = Image.open('Second.png')
im3 = Image.open('Third.png')
im4 = Image.open('Fourth.png')
get_concat_v().save('concat_v.png')
How can I loop through a folder that has multiple images (Say 9 images) and merge every four images into one image? So the final folder should have three images (the first image would contain 4 images, the second image would contain 4 images, the third image would contain 1 image)