Отразить по горизонтали изображение в Python (JES)
Мне нужно сделать функцию, которая будет копировать изображение, но зеркально. Я создал код для зеркального отображения изображения, но это не такне работаю, а я нетЯ не знаю почему, потому что я проследил код, и он должен отражать изображение. Вот's код:
def invert(picture):
width = getWidth(picture)
height = getHeight(picture)
for y in range(0, height):
for x in range(0, width):
sourcePixel = getPixel(picture, x, y)
targetPixel = getPixel(picture, width - x - 1, height - y - 1)
color = getColor(sourcePixel)
setColor(sourcePixel, getColor(targetPixel))
setColor(targetPixel, color)
show(picture)
return picture
def main():
file = pickAFile()
picture = makePicture(file)
newPicture = invert(picture)
show(newPicture)
Может кто-нибудь объяснить мне, что не так? Спасибо.