Add a function that merge images into one image and split it again smartly