Created by CyanHall.com on 12/23/2020 , Last updated: 01/08/2021.
👉  github shields Star me if it’s helpful.
    // -90 degrees
func rotateImage(image:UIImage) -> UIImage 
{
    var rotatedImage = UIImage()
    switch image.imageOrientation
    {
        case .right:
            rotatedImage = UIImage(cgImage: image.cgImage!, scale: 1.0, orientation: .up
        case .down:
            rotatedImage = UIImage(cgImage: image.cgImage!, scale: 1.0, orientation: .right
        case .left:
            rotatedImage = UIImage(cgImage: image.cgImage!, scale: 1.0, orientation: .down
        default:
            rotatedImage = UIImage(cgImage: image.cgImage!, scale: 1.0, orientation: .left)
    }
    return rotatedImage
}
  
From StackOverflow: iOS - UIImageView - how to handle UIImage image orientation
Maitained by Cyanhall.com, Copy Rights @ CC BY-NC-SA 4.0