Skip to content
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

Can't properly render images with exif data #101

Closed
4leyam opened this issue Apr 14, 2020 · 6 comments · Fixed by #102
Closed

Can't properly render images with exif data #101

4leyam opened this issue Apr 14, 2020 · 6 comments · Fixed by #102
Labels
apple bug Apple's bug that need workaround

Comments

@4leyam
Copy link

4leyam commented Apr 14, 2020

hello, first of all thank you guys for this useful library, my problem here is that i'm having an issue to correctly display an 2700x2160 image containing exif data (orientation) on a real device (iPhone 7) the following is the code that i'm using

WebImage(url: URL(string: "https://dv6mh24acw2xi.cloudfront.net/public/moments/gabbr/tmpImg9143171451882065582.jpeg" )).resizable().placeholder { Rectangle().fill(Color(UIColor.systemBackground)).overlay(Text("loading...")) }.scaledToFit()

i don't know if i'm the one doing it wrong or if there is actually a problem
thanks for your help.

@dreampiggy
Copy link
Collaborator

dreampiggy commented Apr 15, 2020

You’re not doing wrong. It indeed a SwiftUI bug. You can not render it correctly with SwiftUI.Image via a UIImage initializer either.

See more: onevcat/Kingfisher#1395

We can provide a fix, but it’s complicated compared to Kingfisher. The loaded image can be subclass of UIImage, or can contains vector image data, both of cases that Kingfisher’s normalized method (Which is called on main queue...) does not handle. Which will cause huge performance FPS drop and new more issues. I don't think their solution is correct.

If you really want our framework, to handle a bug that SwiftUI team itself cause, I can do some protect by rendered the loaded image with a dummy CGImage based instead. But I doubt this will cause more RAM usage even for normal non-EXIF images.

PS: Not feel this is the correct way for developer to handle. We need to fire radar to Apple. Because if there are 100 Image Loading frameworks on the world, you have to ask 100 authors to do the same things.

@dreampiggy
Copy link
Collaborator

dreampiggy commented Apr 15, 2020

Actually, WebImage is a struct If SwiftUI.Image works, it works. But if SwiftUI.Image not works, it may not works either 😼

@dreampiggy dreampiggy added the apple bug Apple's bug that need workaround label Apr 15, 2020
@dreampiggy
Copy link
Collaborator

@4leyam I found the Image(decorative: cgImage, scale: image.scale, orientation: orientation) actually works for EXIF image and aspectRatio modifier.

image

For vector images, I decide to handle this suck in framework itself. If you load PDF/SVG vector images on WebImage, it will automatically generate a bitmap with the PDF/SVG default size(may be small than your rendering ImageView's size), at least you don't need previous version's hack code from user side:

https://github.com/SDWebImage/SDWebImageSwiftUI/blob/1.3.2/Example/SDWebImageSwiftUIDemo/AppDelegate.swift#L33-L36

@dreampiggy
Copy link
Collaborator

dreampiggy commented Apr 15, 2020

Hack, but works :). Good SwiftUI

For this EXIF images, the hack does not have any performance cost compared to Kingfisher's normalized logic (Which will create a bitmap context in main queue and block)

image

@dreampiggy
Copy link
Collaborator

dreampiggy commented Apr 15, 2020

1.3.3 version released, please upgrade to have to try.

This version fix the cases for EXIF (5-8) images rendering issue on WebImage. Also render the vector images as bitmap by default (previously will show empty)

@4leyam
Copy link
Author

4leyam commented Apr 17, 2020

hey, sorry for the late reply, and thank you for your help and quick reply, it's correctly working now once again thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apple bug Apple's bug that need workaround
Projects
None yet
2 participants