metatext/Extensions/UIImage+Extensions.swift

20 lines
442 B
Swift
Raw Normal View History

2021-02-09 04:33:49 +00: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
}
}