Skip to content

Commit 1b23e14

Browse files
committed
Only apply the patch for EXIF 5-8 images, not including 1-4 images, I think this should be fixed by SwiftUI team :)
1 parent c4a01c9 commit 1b23e14

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Example/SDWebImageSwiftUIDemo/ContentView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct ContentView: View {
8181
"https://nr-platform.s3.amazonaws.com/uploads/platform/published_extension/branding_icon/275/AmazonS3.png",
8282
"https://raw.githubusercontent.com/ibireme/YYImage/master/Demo/YYImageDemo/mew_baseline.jpg",
8383
"https://via.placeholder.com/200x200.jpg",
84-
"https://raw.githubusercontent.com/recurser/exif-orientation-examples/master/Landscape_2.jpg",
84+
"https://raw.githubusercontent.com/recurser/exif-orientation-examples/master/Landscape_5.jpg",
8585
"https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/w3c.svg",
8686
"https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/wikimedia.svg",
8787
"https://raw.githubusercontent.com/icons8/flat-color-icons/master/pdf/stack_of_photos.pdf",

SDWebImageSwiftUI/Classes/WebImage.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ public struct WebImage : View {
146146
cgImage = image.cgImage
147147
}
148148
}
149-
// Case 2: Image with EXIF orientation
150-
else if image.imageOrientation != .up {
149+
// Case 2: Image with EXIF orientation (only EXIF 5-8 contains bug)
150+
else if [.left, .leftMirrored, .right, .rightMirrored].contains(image.imageOrientation) {
151151
cgImage = image.cgImage
152152
}
153153
// If we have CGImage, use CGImage based API, else use UIImage based API

Tests/WebImageTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@ class WebImageTests: XCTestCase {
135135

136136
func testWebImageEXIFImage() throws {
137137
let expectation = self.expectation(description: "WebImage EXIF image url")
138-
// EXIF 2, Up Mirrored
139-
let imageUrl = URL(string: "https://raw.githubusercontent.com/recurser/exif-orientation-examples/master/Landscape_2.jpg")
138+
// EXIF 5, Left Mirrored
139+
let imageUrl = URL(string: "https://raw.githubusercontent.com/recurser/exif-orientation-examples/master/Landscape_5.jpg")
140140
let imageView = WebImage(url: imageUrl)
141141
let introspectView = imageView.onSuccess { image, cacheType in
142142
let displayImage = try? imageView.inspect().group().image(0).cgImage()
143143
let orientation = try! imageView.inspect().group().image(0).orientation()
144144
XCTAssertNotNil(displayImage)
145-
XCTAssertEqual(orientation, .upMirrored)
145+
XCTAssertEqual(orientation, .leftMirrored)
146146
expectation.fulfill()
147147
}.onFailure { error in
148148
XCTFail(error.localizedDescription)

0 commit comments

Comments
 (0)