Search code examples
swiftexifphimagemanager

iOS Identifying a photo taken on smartphone / digital camera vs downloaded from a messenger


G'day I have a task to process images and videos from a user's photo library (iOS), exclude the assets potentially downloaded or saved from a messenger app. Now of course it's not a perfect solution and there can be false positives which is fine. Just have been wondering what a good way is to go about this.

I'm looking at this problem from the point where messenger apps usually strips out exif data from a video and image so things such as location, camera information, author etc are not available on the asset.

What I have tried so far,

  • PhAsset with location are included, and absence is marked as potential exclusion. Now this needs further looking into as sometimes photos from digital camera and may not include location data when importing to user's library.

  • Grab exif data from AVAsset and UIImage from PHImageManager, but I realised the exif data itself is a very broad and deep subject on it's own and wondering if there is an easier way suitable for the task at hand to quickly process exif data or what fields to look out for (I'm not subject expert on image and video exif formats)

Thanks


Solution

  • Resolved this using album names exclusions which seem to be doing a decent enough job. Will return to exif processing if/as needed.

    You can fetch PHAssetCollections and enumerate them to build up a PHAsset collection array. You can exclude these from all PHAssets to get what you want.