Obj-C Check if image already exists in Photos gallery

跟風遠走 提交于 2019-12-01 21:18:18

I have a solution but not one that applies to every situation.

The thing about saving image to camera roll is that there is an assetURL created when you add the image to camera roll. Also, this asset URL is new every time, so if you save to camera roll, it will create a copy. The name of the image is also not retained.

If the image is added to the camera roll through your app in the first place, then you can store the assetURL as part of image information.

In my app, a dictionary is maintained for every image containing some critical info. This includes the assetURL of the image if it is saved to camera roll.

Once you have the URL, you can check its existence by using fetchAssetsWithALAssetURLs:options: function.

If the URL is nil or the asset when fetched is nil, it means that the image does not exist in the camera roll. So you can add anew.

Anand Suthar

There is no easy way to compare two images and if you found one that will surly a heavy task, instead of this we can compare image's meta data which we can write it to image and also read it from images.

You can use this repo for that

And ALAssetLibrary also have some properties to access an images meta info. If you google with this you will surly get some.

Like this one

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!