I am trying to do this:
#Returns a new image that reflects the top half of image onto the bottom half.
def reflectTopToBot(image):
Below is how I did it horizontally. I cropped the left half of the image, reflected it, and merged it with the other half side by side to create an image that is reflected horizontally down the middle. I am trying to do the same vertically (so that the top half is reflected to the bottom), but I cannot merge the images vertically, if that makes sense.
This is the code that works to reflect right to left. How can I change the merging part of the code so that it merges top and bottom instead of side by side? (The merging part starts at image1_size = image.size)
#Returns a new image that reflects the right of image onto the left half.
def reflectRightToLeft(image):
image = image.transpose(method=Image.Transpose.FLIP_LEFT_RIGHT)
(left, upper, right, lower) = (0, 0, 450, 705)
image = image.crop((left, upper, right, lower))
reflect = image.transpose(method=Image.Transpose.FLIP_LEFT_RIGHT)
image1_size = image.size
new_image = Image.new('RGB',(2*image1_size[0], image1_size[1]), (250,250,250))
new_image.paste(image,(0,0))
new_image.paste(reflect,(image1_size[0],0))
return new_image
try this: