metatext-app-ios-iphone-ipad/Extensions/UIImage+Extensions.swift

20 lines
442 B
Swift
Raw Normal View History

2021-02-09 05:33:49 +01:00
// Copyright © 2021 Metabolist. All rights reserved.
import UIKit
extension UIImage {
var withProperOrientation: UIImage? {
guard imageOrientation != .up else { return self }
UIGraphicsBeginImageContextWithOptions(size, false, scale)
draw(in: .init(origin: .zero, size: size))
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image
}
}