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

Resizing Image With InfoOptions not work #397

Closed
lucio1392 opened this issue Aug 15, 2016 · 3 comments
Closed

Resizing Image With InfoOptions not work #397

lucio1392 opened this issue Aug 15, 2016 · 3 comments

Comments

@lucio1392
Copy link

I have to tried this way to cache and download image with InfoOptions but it's not work well like when I'm using

thumbnailImageView.kf_setImageWithURL(<#T##URL: NSURL?##NSURL?#>, placeholderImage: <#T##Image?#>, optionsInfo: <#T##KingfisherOptionsInfo?#>)

InfoOptions parameter passing not working at least with Transaction Option. When I scrolling my tableview cell, look like image replacing not exactly.

I provide my code below. Please help me. Thank.

`
let imageManager = KingfisherManager.sharedManager

let keyForCaching = NSURL(string: thumbnailImage)?.absoluteString

        let infoOptions : KingfisherOptionsInfo = [.Transition(.Fade(2.0)),
                                                   .ForceTransition]

        imageManager.cache.retrieveImageForKey(keyForCaching!, options: infoOptions, completionHandler: { (imageCached, _) in
            if let image = imageCached {
                self.thumbnailImageView.image = image
            }else{
                self.imageManager.downloader.downloadImageWithURL(NSURL(string: thumbnailImage)!, options: infoOptions, progressBlock: nil, completionHandler: { (image, error, imageURL, originalData) in

                    let scaleImage = image?.imageAspectScaledToFillSize(CGSize(width: 375, height: 185))

                    self.imageManager.cache.storeImage(scaleImage!, forKey: keyForCaching!)

                    self.thumbnailImageView.image = scaleImage

                })
            }
        })

`

@onevcat
Copy link
Owner

onevcat commented Aug 16, 2016

The transition option only works when you use the image extension methods of Kingfisher. Instead of checking the cache of manager, just use the imageView.kf_setImage methods will apply the transition effect.

I could understand that you need to cache the resized images before storing it. It is a feature in plan and will be implemented soon. Currently, you might do the transition yourself if you are using the imageView setter method directly.

Ref: #320

@lucio1392
Copy link
Author

Thank for quick reply. I have 1 more question.

Do you mean only transition option work with image extension methods of Kingfisher or any others options like BackgroundDecode or CacheMemoryOnly have same ?

@onevcat
Copy link
Owner

onevcat commented Aug 17, 2016

All options work with image extensions. But usually the default values are good enough (except for the transition style), so there is no need to set them explicitly unless you really need.

@onevcat onevcat closed this as completed Sep 9, 2016
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

No branches or pull requests

2 participants