title: How to flip image horizontally to save flipped in photo album?
body: <p>I have been trying to flip an <code>UIImage</code> image horizontally so that i can save it in my photo album, everything is working fine and I am able to save the image to photo album but the image although appears flipped in my app is not saved as flipped in the photo album. I am using following code to flip the image:</p>
  
  <pre><code>myImage?.withHorizontallyFlippedOrientation()
  </code></pre>
  
  <p>Note: I am not trying to flip the <code>UIImageView</code>, I am trying to flip the image and save it to a new image variable and assigning the image from that image variable to <code>UIImageView</code>.</p>
  
  <p>Complete IBAction Code:</p>
  
  <pre><code>@IBAction func horizontalFlipBtnPressed(_ sender: Any) {
      if myImageView.image != nil{
      let image = myImageView.image
      tempImage.append((image?.withHorizontallyFlippedOrientation())!)
  
      myImageView.image = tempImage.last
  
  
  
      }
      else{
          print ("there is no image selected")
      }
  }
  </code></pre>
  
  <p>Code for saving in Photos Album:</p>
  
  <pre><code>if myImageView.image != nil{
          var image = myImageView.image
          let imageData = image!.pngData()
          let compressedImage = UIImage(data: imageData!)
          UIImageWriteToSavedPhotosAlbum(compressedImage!, nil, nil, nil)
          let alert = UIAlertController(title: "Saved", message: "Your image has been saved!", preferredStyle: .alert)
          let okAction = UIAlertAction(title: "Ok", style: .default, handler: nil)
          alert.addAction(okAction)
          self.present(alert, animated: true,completion: nil)
  
      }
  </code></pre>