mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-28 19:11:30 +00:00
19 lines
442 B
Swift
19 lines
442 B
Swift
// 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
|
|
}
|
|
}
|