Looking through Apple's documentation for UIImageOrientation
I notice that the images that go with the descriptions are incorrect.
https://developer.apple.com/reference/uikit/uiimageorientation
This has been painful for me, so I'm going to leave this here, with the correct images in the answer in case others find the same.
If people think this shouldn't be here, please comment / vote down and I'll remove.
Here's how I got the correct images:
extension UIImage {
var normalised: UIImage {
if imageOrientation == .up {
return self
}
var normalisedImage: UIImage
let format = UIGraphicsImageRendererFormat.default()
format.scale = scale
format.opaque = true
format.prefersExtendedRange = false
normalisedImage = UIGraphicsImageRenderer(size: size, format: format).image { _ in
draw(in: CGRect(origin: .zero, size: size))
}
return normalisedImage
}
func translated(to orientation: UIImageOrientation) -> UIImage {
guard let cgImage = cgImage else {
return self
}
return UIImage(cgImage: cgImage, scale: 1, orientation: orientation).normalised
}
}
Then using this image as the "base"