title: Flipping Image Python
body: <p>I am trying to flip an image horizontally.</p>
  
  <p>From this:                          </p>
  
  <p><img src="https://i.stack.imgur.com/xB4mo.jpg" alt="Original Pic">                 </p>
  
  <p>To This:</p>
  
  <p><img src="https://i.stack.imgur.com/excyt.jpg" alt="Flipped Pic"></p>
  
  <p>But I keep getting it mirrored half way.</p>
  
  <p>Like This:</p>
  
  <p><img src="https://i.stack.imgur.com/yS8rN.jpg" alt="Result I get"></p>
  
  <p>I am trying to reverse the x-axis index and I don't understand why it is being divided.</p>
  
  <pre><code>def flip(picture):
      height = getHeight(picture)
      width = getWidth(picture)
      newPicture = makeEmptyPicture(width, height)
      x2 = width-1
      for x in range(0, width):
          y2 = 0
          for y in range(0, height):
              pxl = getPixel(picture, x, y)
              newPxl = getPixel(picture, x2, y2)
              color = getColor(pxl)
              setColor(newPxl, color)
              y2 = y2+1
          x2 = x2-1
      return picture
  </code></pre>
  
  <p>The rest of my code:</p>
  
  <pre><code>def d():    
      f = pickAFile()
      picture = makePicture(f)        
      newPicture = copy(picture)        
      writePictureTo(newPicture, r"D:\FOLDER\newPic4.jpg")
      explore(newPicture)
  </code></pre>