Untitled
unknown
python
a year ago
967 B
7
Indexable
def rotate_image(image, rotation):
n = len(image)
if rotation == 90:
return [[image[n - j - 1][i] for j in range(n)] for i in range(n)]
elif rotation == 180:
return [[image[n - i - 1][n - j - 1] for j in range(n)] for i in range(n)]
elif rotation == 270:
return [[image[j][n - i - 1] for j in range(n)] for i in range(n)]
else:
return image
def flip_vertical(image):
return image[::-1]
def flip_horizontal(image):
return [row[::-1] for row in image]
# Step 1: Rotate the image based on the 'rotation' parameter
image = rotate_image(image, rotation)
# Step 2: Flip the image vertically if 'vertical_flip' is 1
if vertical_flip == 1:
image = flip_vertical(image)
# Step 3: Flip the image horizontally if 'horizontal_flip' is 1
if horizontal_flip == 1:
image = flip_horizontal(image)
return imageEditor is loading...
Leave a Comment