dmytro-anokhin / url-image

AsyncImage before iOS 15. Lightweight, pure SwiftUI Image view, that displays an image downloaded from URL, with auxiliary views and local cache.
MIT License
1.1k stars 96 forks source link

Image is rotated from portrait to landscape? #66

Closed aliak00 closed 4 years ago

aliak00 commented 4 years ago

Summary and/or background When the image is displayed in the view it is rotated and then displayed

OS and what device you are using

Version of URLImage library The version of the library where the bug happens: 0.9.13

What you expected would happen The image would display in portrait mode

What actually happens The image is rotated to landscape

Sample code The sample code helps a lot. Try isolating the sample code so it compiles without dependancies.

    var body: some View {
        Group {
            VStack(alignment: .leading) {
                URLImage(
                    url,
                    placeholder: { _ in
                        Text("yo")
                    }
                ) { proxy in
                    proxy.image
                        .resizable()
                        .aspectRatio(contentMode: .fit)
                }
            }
        }
    }

Test data The image in question: https://firebasestorage.googleapis.com/v0/b/ms-chanandler-bong.appspot.com/o/flaneur%2Fplaces%2FRib%2F2020-04-09-qzo7Op?alt=media&token=cfc424dc-4f46-4c56-88d0-bb5463f6f172

Additional information:

It looks like this:

image

dreampiggy commented 4 years ago

See: https://github.com/onevcat/Kingfisher/issues/1395 https://github.com/SDWebImage/SDWebImageSwiftUI/pull/102

Bug: https://twitter.com/DreamingPiggy/status/1250383922921230336

This is SwiftUI's bug, apply for everyone with SwiftUI.Image.

If you still need this, just have a try with SDWebImageSwiftUI, which solve the problem without any performance cost and FPS drop.

aliak00 commented 4 years ago

Thanks for the info @dreampiggy ! I'll have a look at SDWebImageSwiftUI!

Edit: Worked like a charm! :D

aliak00 commented 4 years ago

Does anyone know if there's a workaround using URLImage though?

dmytro-anokhin commented 4 years ago

Hey @aliak00, the sample URL returns 403 (forbidden) for me. Any chance to upload the image to a public server?

aliak00 commented 4 years ago

@dmytro-anokhin sorry! I accidentally deleted it

This one should be the same: https://firebasestorage.googleapis.com/v0/b/ms-chanandler-bong.appspot.com/o/flaneur%2Fplaces%2Fsomeplace%2F2020-04-15-aH7e6V?alt=media&token=6b843ded-922d-4691-90a6-a04a4c0e7e5e

dmytro-anokhin commented 4 years ago

Fixed in 0.9.14. The image must appear correctly when using proxy.image property. @aliak00 please let me know if you can verify it.

aliak00 commented 4 years ago

Checked! It doesn't show up rotated now! 🥳

dmytro-anokhin commented 4 years ago

Great, thanks for verifying.