PhotoKit - Swift 4 - 如何找到相同的照片或重复的照片 - PHFetchResult<PHAsset>

PhotoKit - Swift 4 - How to find identical Photos or duplicate photos - PHFetchResult<PHAsset>

我能够使用以下代码从照片库中获取照片列表。

  guard let assetCollection = collection as? PHAssetCollection
                else { fatalError("asset collection is required.") }
            destination.fetchResult = PHAsset.fetchAssets(in: assetCollection, options: nil) 

destination.fetchResult 根据 PHAssets.I 获取所有照片,想要找到 PHFetchResult 中存在的重复照片。

请提出任何建议。

TL;DR 基于图像元数据相似性或图像相似性的假设可能有效,但不能保证。

照片框架不向您提供有关一张图片与另一张图片的相似程度的信息。你只能假设如果照片是在同一个地方拍摄的(使用PHAsset location and the same time (PHAsset creation date),并且有更多相似的参数。

但不能保证这些图像将完全相同。您还可以使用例如 Image hashing algorithms 来分析图像相似性。祝你好运!