0

I am creating app to save images to Photo library from net. now i want to check every time before saving image to PhotoLibrary that image is already there or not?

i fetch the name of images stored in photo library but that name are different than original name so i don't know how to compare current image with already existing images! please help me!

   ALAssetsLibrary *Library=[[ALAssetsLibrary alloc]init];

   NSMutableArray *arr_ImagesUrl=[[NSMutableArray alloc]init];

   [Library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *Group,BOOL *stop){

    [Group enumerateAssetsUsingBlock:^(ALAsset *asset,NSUInteger index,BOOL *stop)

     {
         NSLog(@"%@",[[asset defaultRepresentation]filename]);
     }];
} failureBlock:^(NSError *error){NSLog(@"%@",error.description);}];

1 Answers1

0

Basically theres is no such API in IOS documentation as far as I know.

What you can do, which is not quite the same as you originally wanted, is that in your application store an individual value (*) for every image the user selected throughout the app lifecycle. Based on this array of information you are able to tell whether a new selection is the same as a previous one. But still, you cannot do this for the full PhotoLibrary.

(*) This is an useful thread on SO which about detecting image similarity and/or creating a value (hash) which describes the image and usable for comparing images later. My favourite is phash.

https://softwareengineering.stackexchange.com/questions/92830/how-to-know-if-two-images-are-the-same

or see this: Compare two images to check if they are same

Community
  • 1
  • 1
nzs
  • 3,252
  • 17
  • 22