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

Image get Rotated after applying ResizingImageProcessor #1355

Closed
HuylensHu opened this issue Nov 24, 2019 · 1 comment · Fixed by #1358
Closed

Image get Rotated after applying ResizingImageProcessor #1355

HuylensHu opened this issue Nov 24, 2019 · 1 comment · Fixed by #1358

Comments

@HuylensHu
Copy link

HuylensHu commented Nov 24, 2019

I searched the issue and read the issue #564,but I still think this is an issue.
The image(https://superdm.oss-cn-hongkong.aliyuncs.com/image/1574569992739.jpg) show correctly without applying ResizingImageProcessor but get rotated after applying ResizingImageProcessor.
my code

let processor = ResizingImageProcessor.init(referenceSize: size, mode:.aspectFill)
                              .append(another: CroppingImageProcessor(size: size))
imageView.kf.indicatorType = .activity
let url = URL.init(string: String(images[index]))!
imageView.kf.setImage(with: url, options: [
    .processor(processor),
    .scaleFactor(UIScreen.main.scale),
    .transition(.fade(1)),
    // .cacheOriginalImage
])

I read the code and think the problem is .kf.resize(to: referenceSize, for: targetContentMode) in ResizingImageProcessor's process, I replace the code

 public func process(
    item: ImageProcessItem, 
    options: KingfisherParsedOptionsInfo
) -> KFCrossPlatformImage? {
    switch item {
     case .image(let image):
         return image.kf.scaled(to: options.scaleFactor)
                              .kf.resize(to: referenceSize, for: targetContentMode)
     case .data:
         return (DefaultImageProcessor.default |> self).process(item: item, options: options)
}

to

 public func process(
    item: ImageProcessItem, 
    options: KingfisherParsedOptionsInfo
) -> KFCrossPlatformImage? {
    switch item {
    case .image(let image):
        return image.kf.scaled(to: options.scaleFactor)
                              .kf.normalized
                              .kf.resize(to: referenceSize, for: targetContentMode)
    case .data:
        return (DefaultImageProcessor.default |> self).process(item: item, options: options)
}

it works well,I consider you can provide a more efficient way to deal with this,

Thanks

@onevcat
Copy link
Owner

onevcat commented Nov 29, 2019

Should be fixed in #1358

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants