alexhillc / AXPhotoViewer

An iOS/tvOS photo gallery viewer, useful for viewing a large (or small!) number of photos.
https://www.cocoacontrols.com/controls/axphotoviewer
MIT License
646 stars 119 forks source link

Live Photos #24

Open vitalrum opened 6 years ago

vitalrum commented 6 years ago

Hi, thanks for good viewer. I have a trouble with Live Photos. I can pick it from library and display it in imageView. But close animation your library work very bad. I think problem with uiimage orientation

vitalrum commented 6 years ago

i have answer. Need to fix orientation of UIImage before present it in ImageView. I use this method (category of UIImage):

func fixedOrientation() -> UIImage {
        if (self.imageOrientation == .up) {
            return self
        }

        UIGraphicsBeginImageContextWithOptions(self.size, false, self.scale)
        let rect = CGRect(x: 0, y: 0, width: self.size.width, height: self.size.height)
        self.draw(in: rect)

        let normalizedImage = UIGraphicsGetImageFromCurrentImageContext()!
        UIGraphicsEndImageContext()

        return normalizedImage
    } 

use like this:

let orientedImage = originalImage.fixedOrientation()

alexhillc commented 6 years ago

Glad you seem to have found a solution to this problem. Perhaps adding an image modification callback to the delegate would be helpful in this scenario.