Odwróć poziomo obraz w Pythonie (JES)

Muszę stworzyć funkcję, która skopiuje obraz, ale będzie lustrzany. Stworzyłem kod, aby odzwierciedlić obraz, ale nie działa i nie wiem dlaczego, ponieważ śledziłem kod i powinien on odzwierciedlać obraz. Oto kod:

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)

Czy ktoś może mi wyjaśnić, co jest nie tak? Dziękuję Ci.

questionAnswers(2)

yourAnswerToTheQuestion