Kingfisher LocalFileImageDataProvider DownsamplingImageProcessor 在内存中调整数据大小
Kingfisher LocalFileImageDataProvider DownsamplingImageProcessor resize data in memory
自从 Kingfisher
从 5.0
引入 LocalFileImageDataProvider
。我决定切换到 Kingfisher
从我的磁盘加载图像而不是直接加载它们。正如他们所说,
// Compared to loading it directly,
// you can get benefit of using Kingfisher's extension methods,
// as well as applying `ImageProcessor`s and storing the image to `ImageCache` of Kingfisher.
效果很好。因为我的磁盘图像非常大(每个超过 1MB)。
所以 问题是如果我在 UICollectionView's Cell
中使用 DownsamplingImageProcessor
调整图像大小,我是否仍然能够在 "Image's detail" 中访问原始大小的图像仍然使用这样的页面来显示全分辨率图像,
//The way loading image from "Image detail page"
let url = URL(fileURLWithPath: path)
let provider = LocalFileImageDataProvider(fileURL: url)
imageView.kf.setImage(with: provider)
所以在"UICollectionView page"我可以这样使用它,
let url = URL(fileURLWithPath: path)
let provider = LocalFileImageDataProvider(fileURL: url)
let processor = DownsamplingImageProcessor(size: size)
imageView.kf.setImage(with: provider, options: [.processor(processor)])
那么他们在Kingfisher缓存机制中是否缓存了不同的图片缓存?因为他们似乎在 LocalFileImageDataProvider
.
中使用相同的 cacheKey
public init(fileURL: URL, cacheKey: String? = nil) {
self.fileURL = fileURL
self.cacheKey = cacheKey ?? fileURL.absoluteString
}
我需要为这两个不同的页面自定义 cacheKey
吗?
您不需要使用不同的缓存键。 processor
有一个标识符,存储在缓存中时将用于计算最终的缓存键。所以一切对你来说应该没问题(作为你的代码片段)。
您可以在图像设置方法完成处理程序中打印出图像大小来确认您正在加载的图像。
imageView.kf.setImage(with: url) { result in
switch result {
case .success(let value):
// The image was set to image view:
print(value.image.size)
//...
自从 Kingfisher
从 5.0
引入 LocalFileImageDataProvider
。我决定切换到 Kingfisher
从我的磁盘加载图像而不是直接加载它们。正如他们所说,
// Compared to loading it directly,
// you can get benefit of using Kingfisher's extension methods,
// as well as applying `ImageProcessor`s and storing the image to `ImageCache` of Kingfisher.
效果很好。因为我的磁盘图像非常大(每个超过 1MB)。
所以 问题是如果我在 UICollectionView's Cell
中使用 DownsamplingImageProcessor
调整图像大小,我是否仍然能够在 "Image's detail" 中访问原始大小的图像仍然使用这样的页面来显示全分辨率图像,
//The way loading image from "Image detail page"
let url = URL(fileURLWithPath: path)
let provider = LocalFileImageDataProvider(fileURL: url)
imageView.kf.setImage(with: provider)
所以在"UICollectionView page"我可以这样使用它,
let url = URL(fileURLWithPath: path)
let provider = LocalFileImageDataProvider(fileURL: url)
let processor = DownsamplingImageProcessor(size: size)
imageView.kf.setImage(with: provider, options: [.processor(processor)])
那么他们在Kingfisher缓存机制中是否缓存了不同的图片缓存?因为他们似乎在 LocalFileImageDataProvider
.
cacheKey
public init(fileURL: URL, cacheKey: String? = nil) {
self.fileURL = fileURL
self.cacheKey = cacheKey ?? fileURL.absoluteString
}
我需要为这两个不同的页面自定义 cacheKey
吗?
您不需要使用不同的缓存键。 processor
有一个标识符,存储在缓存中时将用于计算最终的缓存键。所以一切对你来说应该没问题(作为你的代码片段)。
您可以在图像设置方法完成处理程序中打印出图像大小来确认您正在加载的图像。
imageView.kf.setImage(with: url) { result in
switch result {
case .success(let value):
// The image was set to image view:
print(value.image.size)
//...