Swiftui IGStoryKit Vertical Image flips Horizontal when sharing to Instagram Story from my app
Solution 1:
Super pumped to hear that you're using IGStoryKit (I made it!).
I've faced this issue too. You have to rotate your image before passing it onto IGStoryKit. This is an iOS "issue"
I use this code in one of my apps. Please try it out and let me know if it works for you too!
var fixOrientation: UIImage? {
guard self.imageOrientation != .up else { return self }
UIGraphicsBeginImageContextWithOptions(self.size, false, self.scale)
let rect = CGRect(x: 0,
y: 0,
width: self.size.width,
height: self.size.height)
self.draw(in: rect)
guard let normalizedImage: UIImage = UIGraphicsGetImageFromCurrentImageContext() else { return nil }
UIGraphicsEndImageContext()
return normalizedImage
}
You have to apply this on the image. So, in your case that'd be something like:
let image = UIImage(data: self.picData)!
guard let fixedOrientationImage = image.fixOrientation else { return }
// Now pass this `fixedOrientationImage` to IGDispatcher