Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ShawonAshraf/80e4decdaa5e3383672b6edc6d1d7bf6 to your computer and use it in GitHub Desktop.
Save ShawonAshraf/80e4decdaa5e3383672b6edc6d1d7bf6 to your computer and use it in GitHub Desktop.
import UIKit
import ImageIO
extension CGImagePropertyOrientation {
/**
Converts a `UIImageOrientation` to a corresponding
`CGImagePropertyOrientation`. The cases for each
orientation are represented by different raw values.
- Tag: ConvertOrientation
*/
init(_ orientation: UIImageOrientation) {
switch orientation {
case .up: self = .up
case .upMirrored: self = .upMirrored
case .down: self = .down
case .downMirrored: self = .downMirrored
case .left: self = .left
case .leftMirrored: self = .leftMirrored
case .right: self = .right
case .rightMirrored: self = .rightMirrored
}
}
}
@glofru
Copy link

glofru commented Mar 23, 2021

For newer version of SwiftUI, you should change this:
init(_ orientation: UIImageOrientation)
to this:
init(_ orientation: UIImage.Orientation)

Btw, thank you

@ShawonAshraf
Copy link
Author

I don't work with Swift anymore. Thanks for the update though.

@lexrus
Copy link

lexrus commented Apr 12, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment