-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resized images rotate #14
Comments
Follow up. It appears that my issue was with using a WKWebView. Seems the flag for orientation gets messed up some how. Just switched to using Alamofire for the multipart upload and things seem to be just fine. |
I have the same exact issue, the full size image is the correct direction, but resized one are not |
In 2024 I'm having exactly the same issue |
I fixed this by using another Package along side to get the image data and rotate is again after resizing SwiftExif enum ImageOrientation : Int {
case normal = 1 //= 0 degrees: the correct orientation, no adjustment is required.
case normalMirrored = 2 //= 0 degrees, mirrored: image has been flipped back-to-front.
case upSideDown = 3 //= 180 degrees: image is upside down.
case upSideDownMirrored = 4 //= 180 degrees, mirrored: image has been flipped back-to-front and is upside down.
case leftRotatedMirrored = 5 //= 90 degrees: image has been flipped back-to-front and is on its side.
case leftRotated = 6 //= 90 degrees, mirrored: image is on its side.
case rightRotatedMirrored = 7 //= 270 degrees: image has been flipped back-to-front and is on its far side.
case rightRotated = 8 //= 270 degrees, mirrored: image is on its far side.
func degrees() -> Float {
switch self {
case .normal, .normalMirrored:
return 0
case .upSideDown, .upSideDownMirrored:
return 180
case .leftRotatedMirrored, .leftRotated:
return -90
case .rightRotatedMirrored, .rightRotated:
return 90
}
}
func flip() -> Bool {
switch self {
case .normal, .upSideDown, .leftRotated, .rightRotated:
return false
case .normalMirrored, .upSideDownMirrored, .leftRotatedMirrored, .rightRotatedMirrored:
return true
}
}
}
// MARK :- After Re-Sizing
let exifImage = SwiftExif.Image(imagePath: image).ExifRaw()
if let rawOrientation = exifImage["0"]?["Orientation"], let intOrientation = Int(rawOrientation), let orientation = ImageOrientation(rawValue: intOrientation) {
modifiedImage?.rotate(angle: orientation.degrees())
if orientation.flip() {
modifiedImage?.flip(.horizontal)
}
} |
Resized images uploaded seem to rotate when they are resized. It seems to rotate image taken with the camera directly uploaded from a WebView 90 CCW. Images uploaded from the camera roll seem to rotate 180.
The text was updated successfully, but these errors were encountered: