metatext/Extensions/UIImage+Extensions.swift
2021-02-08 20:33:49 -08:00

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
}
}