Only apply the patch for EXIF 5-8 images, not including 1-4 images, I think this should be fixed by SwiftUI team :)
This commit is contained in:
parent
c4a01c9ba2
commit
1b23e14577
|
@ -81,7 +81,7 @@ struct ContentView: View {
|
|||
"https://nr-platform.s3.amazonaws.com/uploads/platform/published_extension/branding_icon/275/AmazonS3.png",
|
||||
"https://raw.githubusercontent.com/ibireme/YYImage/master/Demo/YYImageDemo/mew_baseline.jpg",
|
||||
"https://via.placeholder.com/200x200.jpg",
|
||||
"https://raw.githubusercontent.com/recurser/exif-orientation-examples/master/Landscape_2.jpg",
|
||||
"https://raw.githubusercontent.com/recurser/exif-orientation-examples/master/Landscape_5.jpg",
|
||||
"https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/w3c.svg",
|
||||
"https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/wikimedia.svg",
|
||||
"https://raw.githubusercontent.com/icons8/flat-color-icons/master/pdf/stack_of_photos.pdf",
|
||||
|
|
|
@ -146,8 +146,8 @@ public struct WebImage : View {
|
|||
cgImage = image.cgImage
|
||||
}
|
||||
}
|
||||
// Case 2: Image with EXIF orientation
|
||||
else if image.imageOrientation != .up {
|
||||
// Case 2: Image with EXIF orientation (only EXIF 5-8 contains bug)
|
||||
else if [.left, .leftMirrored, .right, .rightMirrored].contains(image.imageOrientation) {
|
||||
cgImage = image.cgImage
|
||||
}
|
||||
// If we have CGImage, use CGImage based API, else use UIImage based API
|
||||
|
|
|
@ -135,14 +135,14 @@ class WebImageTests: XCTestCase {
|
|||
|
||||
func testWebImageEXIFImage() throws {
|
||||
let expectation = self.expectation(description: "WebImage EXIF image url")
|
||||
// EXIF 2, Up Mirrored
|
||||
let imageUrl = URL(string: "https://raw.githubusercontent.com/recurser/exif-orientation-examples/master/Landscape_2.jpg")
|
||||
// EXIF 5, Left Mirrored
|
||||
let imageUrl = URL(string: "https://raw.githubusercontent.com/recurser/exif-orientation-examples/master/Landscape_5.jpg")
|
||||
let imageView = WebImage(url: imageUrl)
|
||||
let introspectView = imageView.onSuccess { image, cacheType in
|
||||
let displayImage = try? imageView.inspect().group().image(0).cgImage()
|
||||
let orientation = try! imageView.inspect().group().image(0).orientation()
|
||||
XCTAssertNotNil(displayImage)
|
||||
XCTAssertEqual(orientation, .upMirrored)
|
||||
XCTAssertEqual(orientation, .leftMirrored)
|
||||
expectation.fulfill()
|
||||
}.onFailure { error in
|
||||
XCTFail(error.localizedDescription)
|
||||
|
|
Loading…
Reference in New Issue