mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-22 08:10:59 +00:00
20 lines
442 B
Swift
20 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
|
||
|
}
|
||
|
}
|