Orientation of UIImage image is not reflected in SKTexture

I'm trying to add an image in UIImage format to SpritKit's SKSpriteNode.

When converting a UIImage into a texture to SKTexture and adding it to SKSpriteNode, the image that takes into account the orientation of the image held by the UIImage is not displayed on the screen.

I tried the code below, but the result is identical.

Code1:

let image: UIImage?
let texture: SKTexture = SKTexture(image: image!)
ver imageNode = SKSpriteNode(texture: texture)


Code2:
let image: UIImage?
let cgImage = image?.cgImage
let ciImage = CIImage(cgImage: cgImage!)
let orientedImage = UIImage(cgImage: CIContext(options: nil).createCGImage(ciImage, from: ciImage.extent)!, scale: 0, orientation: image!.imageOrientation)
let texture: SKTexture = SKTexture(image: orientedImage)
ver imageNode = SKSpriteNode(texture: texture)


Code3:
let image: UIImage?
guard let cgImage = image?.cgImage else { return }
let orientedImage = UIImage(cgImage: cgImage, scale: image!.scale, orientation: .up)
let texture = SKTexture(image: orientedImage)
ver imageNode = SKSpriteNode(texture: texture)

Is there a way to ensure that the image orientation is taken into account when displayed?

Replies

Hints for solving the problem can be found on the following website.

iOS - UIImageView - how to handle UIImage image orientation

The code shown above works for displaying images, but it doesn't seem to work when converting to SKTexture.

To achieve this, it is effective to generate a UIImage using UIGraphicsBeginImageContext or to generate a UIImage using CGAffineTransformTranslate or CGAffineTransformRotate.